-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Open
Labels
DocsNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team member
Description
Pandas version checks
- I have checked that the issue still exists on the latest versions of the docs on
main
here
Location of the documentation
https://pandas.pydata.org/docs/dev/reference/api/pandas.Index.where.html#pandas.Index.where
Documentation problem
Right now the docs for where for an Index mention that the other
argument can be an array-like. As opposed to Series.where and DataFrame.where where other can be a Series or DataFrame.
At runtime this works totally fine with a Series or an Index:
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))
Suggested fix for documentation
Should we allow Index/Series type for other
?
Happy to make the PR, we have added this in a PR in pandas-dev/pandas-stubs#1420 so waiting for confirmation of the pandas
team to move forward with it or not.
Thanks!
Metadata
Metadata
Assignees
Labels
DocsNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team member