modin icon indicating copy to clipboard operation
modin copied to clipboard

Remove Series.dt.to_timestamp

Open sfc-gh-mvashishtha opened this issue 1 year ago • 3 comments

There's no such method in pandas: https://github.com/modin-project/modin/blob/9fa326f6fd53eb0e3192b3eca72382a6388117fe/modin/pandas/series_utils.py#L823

sfc-gh-mvashishtha avatar Apr 30 '24 12:04 sfc-gh-mvashishtha

@sfc-gh-mvashishtha are you sure?

>>> import pandas as pd
>>> pd.Series.dt.to_timestamp
<function PandasDelegate._add_delegate_accessors.<locals>._create_delegator_method.<locals>.f at 0x00000242B5964430>
>>> pd.__version__
'2.2.2'
>>>

anmyachev avatar Apr 30 '24 13:04 anmyachev

This might be a docs issue, I don't see it in the sidebar of official pandas docs (https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.dt.time.html is valid, but https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.dt.to_timestamp.html is not).

noloerino avatar Apr 30 '24 17:04 noloerino

Series.dt.to_timestamp() is a valid method for PeriodProperties, but not for DatetimeProperties, TimedeltaProperties. For example, following is valid:

>>> seconds_series = pd.Series(pd.period_range(start="2000-01-01 00:00:00", end="2000-01-01 00:00:03", freq="s"))
>>> seconds_series
0    2000-01-01 00:00:00
1    2000-01-01 00:00:01
2    2000-01-01 00:00:02
3    2000-01-01 00:00:03
dtype: period[s]
>>> seconds_series.dt.to_timestamp()
0   2000-01-01 00:00:00
1   2000-01-01 00:00:01
2   2000-01-01 00:00:02
3   2000-01-01 00:00:03
dtype: datetime64[ns]

However, it is invalid for timedelta:

>>> seconds_series = pd.Series(pd.timedelta_range(start="1 second", periods=3, freq="s"))
>>> seconds_series.dt.to_timestamp()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'TimedeltaProperties' object has no attribute 'to_timestamp'
>>> seconds_series
0   0 days 00:00:01
1   0 days 00:00:02
2   0 days 00:00:03
dtype: timedelta64[ns]

This might be a problem for both doc and implementation.

gh-yzou avatar May 01 '24 07:05 gh-yzou