Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Open
@WillAyd

Description

@WillAyd
Issue body actions

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'

Metadata

Metadata

Labels

Arrowpyarrow functionalitypyarrow functionalityBugDatetimeDatetime data dtypeDatetime data dtypeIndexRelated to the Index class or subclassesRelated to the Index class or subclasses

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.