Skip to content
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

Remove Series.dt.to_timestamp #7232

Open
sfc-gh-mvashishtha opened this issue Apr 30, 2024 · 3 comments
Open

Remove Series.dt.to_timestamp #7232

sfc-gh-mvashishtha opened this issue Apr 30, 2024 · 3 comments
Labels
P3 Very minor bugs, or features we can hopefully add some day. pandas concordance 🐼 Functionality that does not match pandas

Comments

@sfc-gh-mvashishtha
Copy link
Contributor

There's no such method in pandas:

def to_timestamp(self, *args, **kwargs):

@sfc-gh-mvashishtha sfc-gh-mvashishtha added pandas concordance 🐼 Functionality that does not match pandas P3 Very minor bugs, or features we can hopefully add some day. labels Apr 30, 2024
@anmyachev
Copy link
Collaborator

@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'
>>>

@noloerino
Copy link
Collaborator

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).

@gh-yzou
Copy link

gh-yzou commented May 1, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Very minor bugs, or features we can hopefully add some day. pandas concordance 🐼 Functionality that does not match pandas
Projects
None yet
Development

No branches or pull requests

4 participants