pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.58k stars 17.9k forks source link

Option to change pandas.Timestamp format when printing dataframe #23220

Open teto opened 6 years ago

teto commented 6 years ago

Problem description

To use pandas.rolling, I had to convert my float64 nanoseconds timestamps to pandas.Timestamp. Timestamps now appear nicer on matplotlib plots but when debugging and plotting df.head(), i would like to see the timestamp in nanosecond format rather than Timestamp.__repr()__ that prints the day/month/year (in my case the same for every row).

Every (stackoverflow) I could find recommand to create a new column with the right format. I would like to avoid that since I find it overkill. As it's a temporary/printing issue, I think it falls into https://pandas.pydata.org/pandas-docs/stable/options.html#available-options and I would be happy with that. What do you think ?

Expected Output

Version 0.23.4

jreback commented 6 years ago

this is a duplicate issue pls search the issue history

nmusolino commented 5 years ago

You could write a one-line function that returns the raw time stamp value from a pandas.Timestamp value, then pass that function to Styler.format for the column in question. I can explain in more detail if needed.

The Styler works in Jupiter notebooks, but isn’t very useful in plain-text iPython or Python REPL.