-
-
Notifications
You must be signed in to change notification settings - Fork 150
Open
Description
Describe the bug
DataFrame.loc
does not like Sequence[Hashable]
for the columns
To Reproduce
Script
from collections.abc import Hashable, Sequence
from typing import cast
import pandas as pd
a = cast(Sequence[Hashable], ["a"])
pd.DataFrame({"a": [1]}).loc[:, a]
Typechecker
pyright
Error message
ttest.py:7:1 - error: No overloads for "__getitem__" match the provided arguments (reportCallIssue)
ttest.py:7:1 - error: Argument of type "tuple[slice[None, None, None], Sequence[Hashable]]" cannot be assigned to parameter "idx" of type "tuple[Scalar, slice[Any, Any, Any]]" in function "__getitem__"
"tuple[slice[None, None, None], Sequence[Hashable]]" is not assignable to "tuple[Scalar, slice[Any, Any, Any]]"
Tuple entry 1 is incorrect type
Type "slice[None, None, None]" is not assignable to type "Scalar"
"slice[None, None, None]" is not assignable to "str"
"slice[None, None, None]" is not assignable to "bytes"
"slice[None, None, None]" is not assignable to "date"
"slice[None, None, None]" is not assignable to "datetime"
"slice[None, None, None]" is not assignable to "timedelta" (reportArgumentType)
2 errors, 0 warnings, 0 informations
Informations
- version of type checker: 1.1.406
- version of installed
pandas-stubs
:main
Metadata
Metadata
Assignees
Labels
No labels