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

ENH: ArrowTemporalProperties' object has no attribute 'to_period' #59771

Open
1 of 3 tasks
dbalabka opened this issue Sep 10, 2024 · 4 comments
Open
1 of 3 tasks

ENH: ArrowTemporalProperties' object has no attribute 'to_period' #59771

dbalabka opened this issue Sep 10, 2024 · 4 comments
Labels
Arrow pyarrow functionality Datetime Datetime data dtype Enhancement Needs Discussion Requires discussion from core team before further action

Comments

@dbalabka
Copy link

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

This request is related to #52321 and #52330. Currently, Arrow dtype does not support function: https://pandas.pydata.org/docs/reference/api/pandas.Series.to_period.html

Feature Description

The following script throws an error:

import pandas as pd
from datetime import datetime

s = pd.Series([datetime.now()], dtype='date32[pyarrow]')
s.dt.to_period('D')
AttributeError: 'ArrowTemporalProperties' object has no attribute 'to_period'

Alternative Solutions

Otherwise, it requires convert arrow type back to pandas type which is not efficient:

import pandas as pd
from datetime import datetime

s = pd.Series([datetime.now()], dtype='date32[pyarrow]')
pd.to_datetime(s).dt.to_period('D')

Additional Context

No response

@dbalabka dbalabka added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 10, 2024
@rhshadrach
Copy link
Member

Since this works on datetime64[s] it seems reasonable to have it work on pyarrow dtypes.

@jbrockmendel - that sound right?

@rhshadrach rhshadrach added Datetime Datetime data dtype Arrow pyarrow functionality Needs Discussion Requires discussion from core team before further action and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 30, 2024
@jbrockmendel
Copy link
Member

The requested feature would be identical to .astype(“period[D]”). I don’t mind supporting it, but would also be ok with saying we want Just One Way. Side-note: datetime64 corresponds to timestamp[pyarrow], not date32[pyarrow].

@rhshadrach
Copy link
Member

would also be ok with saying we want Just One Way.

I think that would mean deprecating to_period, is that right?

@jbrockmendel
Copy link
Member

I just meant not adding it here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Datetime Datetime data dtype Enhancement Needs Discussion Requires discussion from core team before further action
Projects
None yet
Development

No branches or pull requests

3 participants