Skip to content

lisa: Fix uses of Index.get_indexer()

FIX

Pandas currently recommands replacing uses of the deprecated Index.get_loc(x) by Index.get_indexer([x]).

https://github.com/pandas-dev/pandas/issues/46763

This is unfortunately not accurate and results in breakages:

  • get_loc(x) returns an integer
  • get_indexer([x]) returns an array of integer

Using DataFrame.iloc[] on the output of get_indexer() will therefore give a single-row dataframe instead of a series, which leads to various issues.

Replace get_indexer([x]) by get_indexer([x])[0] instead.

Merge request reports