Add unit property and as_unit method to DatetimeIndex, TimedeltaIndex and Series.dt by skatsuta · Pull Request #865 · pandas-dev/pandas-stubs (original) (raw)
- Tests added: Please use
assert_type()to assert the type of any return value
Add unit property and as_unit method to DatetimeIndex, TimedeltaIndex and Series.dt,
to add support for the following items in #624:
- Added DatetimeIndex.as_unit() and TimedeltaIndex.as_unit() to convert to different resolutions; supported resolutions are “s”, “ms”, “us”, and “ns”
- Added Series.dt.unit() and Series.dt.as_unit() to convert to different resolutions; supported resolutions are “s”, “ms”, “us”, and “ns”
Note: The addition to TimelikeOps is not necessarily needed to add support for Series.dt, but since it is in the pandas implementation, we should also add it in this stub for consistency.