8000 BUG: set_index with pyarrow timestamp type does not produce DatetimeIndex · Issue #60561 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content
BUG: set_index with pyarrow timestamp type does not produce DatetimeIndex #60561
Open
@WillAyd

Description

@WillAyd

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

Arrow 3DEC pyarrow functionalityBugDatetimeDatetime data dtypeIndexRelated 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

    0