-
-
Notifications
You must be signed in to change notification settings - Fork 148
Closed
Labels
ExtensionArrayExtending pandas with custom dtypes or arrays.Extending pandas with custom dtypes or arrays.IndexRelated to the Index class or subclassesRelated to the Index class or subclassesgood first issue
Description
Describe the bug
to_datetime().array
gives the generic ExtensionArray
, but it turns out to be DatetimeArray
at run time.
Reproduce
Minimal runnable example
from typing import assert_type
import pandas as pd
arr = pd.to_datetime(["2020-01-01", "2020-01-02"]).array
assert_type(arr, pd.arrays.DatetimeArray) # type checker: ExtensionArray
assert isinstance(arr, pd.arrays.DatetimeArray) # no exception
Error messages
pyright
error: "assert_type" mismatch: expected "DatetimeArray" but received "ExtensionArray" (reportAssertTypeFailure)
mypy
error: Expression is of type "ExtensionArray", not "DatetimeArray" [assert-type]
Please complete the following information
- OS: Windows
- OS Version: 11
- python version: 3.12.10
- version of type checker
- mypy 1.17.1 (compiled: yes)
- pyright 1.1.405
- version of installed
pandas-stubs
: 2.3.2.250827
Additional context
Nope
Metadata
Metadata
Assignees
Labels
ExtensionArrayExtending pandas with custom dtypes or arrays.Extending pandas with custom dtypes or arrays.IndexRelated to the Index class or subclassesRelated to the Index class or subclassesgood first issue