Using pandas.DataFrame.loc
with a tuple[str, str]
multi-index seems to elicit mypy
errors
#466
Labels
Describe the bug
Using
pandas.DataFrame.loc
with a multi-index -- expressed as atuple[str, str]
, per the syntax described in https://pandas.pydata.org/docs/user_guide/advanced.html#advanced-indexing-with-hierarchical-index -- seems to elicitmypy
errors.To Reproduce
Running
mypy
version 0.991 on that source code yields the following error:Invalid index type "Tuple[str, Tuple[str, str]]" for "_LocIndexerFrame"; expected type "Union[Series[bool], ndarray[Any, dtype[bool_]], List[bool], str, Tuple[Union[Index, Union[Series[bool], ndarray[Any, dtype[bool_]], List[bool]], Union[str, bytes, date, datetime, timedelta, bool, int, float, complex, Timestamp, Timedelta], List[Any], slice], ...], List[<nothing>]]" [index]
Please complete the following information:
Additional context
I tried changing
pandas-stubs/pandas-stubs/core/frame.pyi
Line 161 in 58416f2
_LocIndexerFrame.__getitem__
as well, so I may try that, and if it works, I'll submit a PR.The text was updated successfully, but these errors were encountered: