Closed
Description
Describe the bug
DataFrame.drop
with columns=set(...)
is unspecified.
To Reproduce
- Provide a minimal runnable
pandas
example that is not properly checked by the stubs.
import pandas as pd
df = pd.DataFrame({1: [2], 3: [4]})
df = df.drop(columns={1})
- I am using
mypy
type checker. - The error message received from that type checker.
df_drop.py:4:6: error: No overload variant of "drop" of "NDFrame" matches argument type "set[int]" [call-overload]
df_drop.py:4:6: note: Possible overload variants:
df_drop.py:4:6: note: def drop(self, labels: None = ..., *, axis: Literal['index', 0] | Literal['columns', 1] = ..., index: Hashable | Sequence[Hashable] | Index[Any] = ..., columns: Hashable | Sequence[Hashable] | Index[Any], level: Hashable | int | None = ..., inplace: Literal[True], errors: Literal['ignore', 'raise'] = ...) -> None
df_drop.py:4:6: note: def drop(self, labels: None = ..., *, axis: Literal['index', 0] | Literal['columns', 1] = ..., index: Hashable | Sequence[Hashable] | Index[Any], columns: Hashable | Sequence[Hashable] | Index[Any] = ..., level: Hashable | int | None = ..., inplace: Literal[True], errors: Literal['ignore', 'raise'] = ...) -> None
df_drop.py:4:6: note: def drop(self, labels: Hashable | Sequence[Hashable] | Index[Any], *, axis: Literal['index', 0] | Literal['columns', 1] = ..., index: None = ..., columns: None = ..., level: Hashable | int
| None = ..., inplace: Literal[True], errors: Literal['ignore', 'raise'] = ...) -> None
df_drop.py:4:6: note: def drop(self, labels: None = ..., *, axis: Literal['index', 0] | Literal['columns', 1] = ..., index: Hashable | Sequence[Hashable] | Index[Any] = ..., columns: Hashable | Sequence[Hashable] | Index[Any], level: Hashable | int | None = ..., inplace: Literal[False] = ..., errors: Literal['ignore', 'raise'] = ...) -> DataFrame
df_drop.py:4:6: note: def drop(self, labels: None = ..., *, axis: Literal['index', 0] | Literal['columns', 1] = ..., index: Hashable | Sequence[Hashable] | Index[Any], columns: Hashable | Sequence[Hashable] | Index[Any] = ..., level: Hashable | int | None = ..., inplace: Literal[False] = ..., errors: Literal['ignore', 'raise'] = ...) -> DataFrame
df_drop.py:4:6: note: def drop(self, labels: Hashable | Sequence[Hashable] | Index[Any], *, axis: Literal['index', 0] | Literal['columns', 1] = ..., index: None = ..., columns: None = ..., level: Hashable | int
| None = ..., inplace: Literal[False] = ..., errors: Literal['ignore', 'raise'] = ...) -> DataFrame
df_drop.py:4:6: note: def drop(self, labels: None = ..., *, axis: Literal['index', 0] | Literal['columns', 1] = ..., index: Hashable | Sequence[Hashable] | Index[Any] = ..., columns: Hashable | Sequence[Hashable] | Index[Any], level: Hashable | int | None = ..., inplace: bool = ..., errors: Literal['ignore', 'raise'] = ...) -> DataFrame | None
df_drop.py:4:6: note: def drop(self, labels: None = ..., *, axis: Literal['index', 0] | Literal['columns', 1] = ..., index: Hashable | Sequence[Hashable] | Index[Any], columns: Hashable | Sequence[Hashable] | Index[Any] = ..., level: Hashable | int | None = ..., inplace: bool = ..., errors: Literal['ignore', 'raise'] = ...) -> DataFrame | None
df_drop.py:4:6: note: def drop(self, labels: Hashable | Sequence[Hashable] | Index[Any], *, axis: Literal['index', 0] | Literal['columns', 1] = ..., index: None = ..., columns: None = ..., level: Hashable | int
| None = ..., inplace: bool = ..., errors: Literal['ignore', 'raise'] = ...) -> DataFrame | None
Found 1 error in 1 file (checked 1 source file)
Please complete the following information
- OS: Windows
- OS Version:
[System.Environment]::OSVersion.Version
Major Minor Build Revision
----- ----- ----- --------
10 0 19045 0
- python version:
Python 3.11.9
- version of type checker:
mypy 1.11.2 (compiled: yes)
- version of installed
pandas-stubs
:pandas-stubs==2.2.2.240807
Additional context
Nope