Description
pandas deprecates the method
keyword in Index.get_loc
, see pandas-dev/pandas#42269. Therefore we end up with about 5000 warnings in our upstream tests:
FutureWarning: Passing method to Index.get_loc is deprecated and will raise in a future version. Use index.get_indexer([item], method=...) instead
We should fix this before pandas releases because the warning will not be silent (FutureWarning
) or ask pandas to give us more time and use a DeprecationWarning
at the moment.
We use this here:
Lines 233 to 235 in 4bb9d9c
Is this only ever called with one item? Then we might be able to use
indexer = self.index.get_indexer(
[label_value], method=method, tolerance=tolerance
).item()
if indexer == -1:
raise KeyError(label_value)
Lines 571 to 572 in 3956b73
This one could be easy to fix (replace with
imin = index.get_indexer([minval], method="nearest").item()
)
It is also defined in CFTimeIndex
, which complicates things:
xarray/xarray/coding/cftimeindex.py
Lines 461 to 466 in eea7673
because get_indexer
expects an iterable and thus the if isinstance(key, str)
test no longer works.