Pandas version checks

  • [x] 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/pandas-docs/stable/reference/api/pandas.Series.reindex.html
  • https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.reindex.html

Documentation problem

The following code snippet works:

import pandas as pd

sr = pd.Series([1, 2], pd.to_datetime(["2023-01-01", "2023-01-02"]))
sr.reindex(index=pd.to_datetime(["2023-01-02", "2023-01-03"]), method="ffill", tolerance=pd.Timedelta("1D"))

df = sr.to_frame()
df.reindex(index=pd.to_datetime(["2023-01-02", "2023-01-03"]), method="ffill", tolerance=pd.Timedelta("1D"))

but in the documentation, tolerance being Timedelta is undefined.

Suggested fix for documentation

Append Timedelta in the documentation for tolerance.

Comment From: loicdiridollou

In the docs I see that the value for tolerance can be a scalar so Timedelta falls into that category (see the definition of Scalar in pandas/_typing.py). If anything you could correct the docstring as it says that in the case of a list it needs to match the dtype of the index which is misguiding since the subtraction of two Timestamps is not a Timestamp but a timedelta.

Let me know if I missed something!