pd.Timedelta.resolution is different from datetime.timedelta.resolution · Issue #21344 · pandas-dev/pandas (original) (raw)

@mroeschke

timedelta.resolution is documented as:

The smallest possible difference between non-equal timedelta objects, timedelta(microseconds=1).

while pandas.Timedelta.resolution is doc-string'd as:

return a string representing the lowest resolution that we have

In [9]: pd.Timedelta(minutes=30).resolution
Out[9]: 'T'

In [10]: timedelta(minutes=30).resolution
Out[10]: datetime.timedelta(0, 0, 1)

I think this difference should be addressed by either:

  1. Documenting the difference between both but also supporting datetime.timedelta's notion of resolution in Timedelta (i.e. something that returns Timedelta(nanoseconds=1))
  2. Making Timedelta.resolution consistent with timedelta.resolution and creating a new property for "the lowest resolution" of a Timedelta instance

Thoughts?

xref #21336