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

BUG: set_index with pyarrow timestamp type does not produce DatetimeIndex #60561

Open
3 tasks done
WillAyd opened this issue Dec 13, 2024 · 2 comments
Open
3 tasks done
Assignees
Labels
Arrow pyarrow functionality Bug Datetime Datetime data dtype Index Related to the Index class or subclasses

Comments

@WillAyd
Copy link
Member

WillAyd commented Dec 13, 2024

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import io

import pandas as pd

buf = io.StringIO("date,value\n2024-01-01 00:00:00,1\n2024-02-01 00:00:00,2")
df = pd.read_csv(buf, parse_dates=["date"])
df.set_index("date").loc["2024-01"] # works


buf = io.StringIO("date,value\n2024-01-01 00:00:00,1\n2024-02-01 00:00:00,2")
df = pd.read_csv(buf, parse_dates=["date"], dtype_backend="pyarrow", engine="pyarrow")
df.set_index("date").loc["2024-01"]  # KeyError


### Issue Description

The pyarrow timestamp type gets put into a generic `Index` when assigned via set_index, so the datetime overloads do not work correctly

### Expected Behavior

The pyarrow timestamp type should be wrapped by a DatetimeIndex

### Installed Versions

3.0.0.dev0+1696.gfae3e8034f'
@WillAyd WillAyd added Bug Needs Triage Issue that has not been reviewed by a pandas team member Datetime Datetime data dtype Index Related to the Index class or subclasses Arrow pyarrow functionality and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 13, 2024
@WillAyd
Copy link
Member Author

WillAyd commented Dec 13, 2024

I think this is another one to keep track of for PDEP-13 #58455

@AbhishekChaudharii
Copy link
Contributor

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Bug Datetime Datetime data dtype Index Related to the Index class or subclasses
Projects
None yet
Development

No branches or pull requests

2 participants