TimedeltaIndex should have a method to help to convert to string (with a custom format with microsecond resolution) #26897
Labels
Enhancement
Needs Discussion
Requires discussion from core team before further action
Timedelta
Timedelta data type
Hello,
I noticed in doc https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.dt.strftime.html that
DatetimeIndex
have adt
attribute which can help to convert aTimestamp
to string.(or
rng.to_series().dt.strftime('%B %d, %Y, %r')
)A similar method should exist for
TimedeltaIndex
to help to convert it to string (it's especially useful to output an Excel files without "0 days" for each index when each timedelta is below 1 day)I have found a bad method to do this:
unfortunatelly it doesn't support the "f" specifier for microsecond (I only need in fact millisecond)
it could be nice to simply be able to do
or naming attribute
td
(instead ofdt
) to avoid confusion betweenDatetimeIndex
andTimedeltaIndex
or even simplier
I think a workaround to achieve this is (with positive
Timedelta
) to add epoch and so manageTimestamp
instead.But I'm still wondering how to manage negative
Timedelta
such asAny idea?
Kind regards
PS : related issue #17232 (about display of negative Timedelta)
The text was updated successfully, but these errors were encountered: