-
-
Couldn't load subscription status.
- Fork 19.2k
Open
Labels
Description
Pandas version checks
- I have checked that the issue still exists on the latest versions of the docs on
mainhere
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!
cmp0xff