Pandas version checks
- [X] I have checked that the issue still exists on the latest versions of the docs on
mainhere
Location of the documentation
Warning when using Float64Index.get_loc:
(Pdb) df.index.get_loc(timestamp, method='ffill')
<stdin>:1: FutureWarning: Passing method to Float64Index.get_loc is deprecated and will raise in a future version. Use index.get_indexer([item], method=...) instead.
Documentation problem
The warning suggests using index.get_indexer(), which seems to work at first but is actually different. get_loc(x) returns an integer, and df.iloc[<integer>] gives a Series. get_indexer([x]) returns an array(<integer>), and df.iloc[array(<integer>)] gives a DataFrame with one row:
import pandas as pd
df = pd.DataFrame(dict(
a=[1,2,3],
))
i = df.index.get_indexer([0], method='ffill')
i2 = df.index.get_loc(0, method='ffill')
print(df.iloc[i].__class__)
print(df.iloc[i2].__class__)
Output:
testdf.py:9: FutureWarning: Passing method to RangeIndex.get_loc is deprecated and will raise in a future version. Use index.get_indexer([item], method=...) instead.
i2 = df.index.get_loc(0, method='ffill')
<class 'pandas.core.frame.DataFrame'>
<class 'pandas.core.series.Series'>
I just corrected a crash where the downstream code was expecting a name attribute on the output value, and there are probably many other ways Series are different from DataFrame.
Suggested fix for documentation
Provide a snippet that is actually equivalent:
<stdin>:1: FutureWarning: Passing method to Float64Index.get_loc is deprecated and will raise in a future version. Use index.get_indexer([item], method=...)[0] instead.
(notice the [0] after get_indexer())
Comment From: simonjayhawkins
Thanks @douglas-raillard-arm for the report.
Can you update the OP to include a reproducible code sample, preferably cut and pastable.
Comment From: NikosAlexandris
Is this something that some end-user action can do away? I see this while trying to plot time series.
Comment From: phofl
Closing since 2.0 is out and Float64Index is removed now