-
-
Notifications
You must be signed in to change notification settings - Fork 150
Open
Description
Describe the bug
Right now Index.where(..., other=...)
only supports the strict array-like (ExtensionArray and np.array), it seems that having Series or Index works at runtime and makes sense.
To Reproduce
- Provide a minimal runnable
pandas
example that is not properly checked by the stubs. - Indicate which type checker you are using (
mypy
orpyright
). - Show the error message received from that type checker while checking your example.
import pandas as pd
import numpy as np
datetime_index = pd.DatetimeIndex(pd.date_range(start="2025-01-01", freq="h", periods=48))
mask = np.ones(48, dtype=bool)
condition = datetime_index.where(mask,datetime_index - pd.Timedelta(days=1))
It yields the following error:
Argument 2 to "where" of "Index" has incompatible type "DatetimeIndex"; expected "str | bytes | date | datetime | timedelta | <13 more items> | None" [arg-type]
Please complete the following information:
- OS: MacOS
- OS Version 26
- python version 3.13
- version of type checker 1.18.1
- version of installed
pandas-stubs
main
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
No labels