-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
FMT: allow datetime/timedelta formatting on a column to be better #3401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Any reason that |
@cancan101 It doesn't matter to preserve that hierarchy. Heck most of those formatters could be collapsed into one just by setting a |
Also for In other words, rather than: It would be a relatively simple change:
to something like:
|
I think the change to repr_timedelta should involve a keyword arg . for the most part u DO want a full repr I think (eg in csv and such) but for output formatting to say the console you could collapse it so need both modes |
My two cents: I like it for your |
@jreback The full repr argument is a bit weak since even now it does not show the day section of the string when the number of days is 0. |
@jtratner I agree that for timedeltas it obscures the output of the data. |
open to various display options |
I think this would be good:
|
and it has the benefit of being round-trippable |
@jtratner iirc the short formats are round trip able as well |
|
yep I needed it for storing timedelta in hdf store actually to_timedelta is pretty well tested for this |
well, if that's the case, I guess I'm fine either way. |
@jtratner Actually in re-reading your post, I think I disagree: as long as |
go for it |
I'll throw together a PR. |
You can do something like the test below to determine whether you have anything but days on all elements
Also might need to handle the 0 days case (instead of just printing 00:00:00) |
@jreback Gotcha. That being said, since The 0 case is somewhat interesting and you would want to know how the rest of the column is output. In other words when timedelta is 0, do you write: |
I think that you should apriori determine which format you want (e.g. a, b, or c), then pass an argument to repr_timedelta to actually format it, maybe call it |
@jreback Do you think is makes sense then for |
exactly what I would do.... This is almost the same as what you need to do for Datetime64 formats as well. You can do it in the formatters, though I think these actually should exist in the so for now, go ahead and put it in the formatters (and a big note to move to the Index classes at some point) @jtratner what do you think? |
slight change: I would create Then we can change code in |
@jreback What code in |
@jreback Do you know why the |
if you have a time zone on anything then u need to write it out fully no matter the date/time |
http://stackoverflow.com/questions/16103238/pandas-timedelta-in-days/16104567#16104567
Its easy to think about, e.g. if no dates in a particular column have time values, then can print them w/o the time values (e.g. just 2001-01-01 maybe), I think this would be nice as the default (maybe add an option for it?)
Better?
The text was updated successfully, but these errors were encountered: