-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC: Should DataFrame.drop()
accept a set
for the columns
, index
and labels
argument?
#59890
Comments
In general, as long as the order is not important for the result, I'm positive on allowing sets. But not strongly so. |
The original method given by drop via pandas package mentions of the following internal type formats. (method)
def drop(
labels: None = ...,
*,
axis: Axis = ...,
index: Hashable | Sequence[Hashable] | Index[Any] = ...,
columns: Hashable | Sequence[Hashable] | Index[Any],
level: Level | None = ...,
inplace: Literal[True],
errors: IgnoreRaise = ...
) -> None: ...
def drop(
labels: None = ...,
*,
axis: Axis = ...,
index: Hashable | Sequence[Hashable] | Index[Any],
columns: Hashable | Sequence[Hashable] | Index[Any] = ...,
level: Level | None = ...,
inplace: Literal[True],
errors: IgnoreRaise = ...
) -> None: ...
def drop(
labels: Hashable | Sequence[Hashable] | Index[Any],
*,
axis: Axis = ...,
index: None = ...,
columns: None = ...,
level: Level | None = ...,
inplace: Literal[True],
errors: IgnoreRaise = ...
) -> None: ...
def drop(
labels: None = ...,
*,
axis: Axis = ...,
index: Hashable | Sequence[Hashable] | Index[Any] = ...,
columns: Hashable | Sequence[Hashable] | Index[Any],
level: Level | None = ...,
inplace: Literal[False] = ...,
errors: IgnoreRaise = ...
) -> DataFrame: ...
def drop(
labels: None = ...,
*,
axis: Axis = ...,
index: Hashable | Sequence[Hashable] | Index[Any],
columns: Hashable | Sequence[Hashable] | Index[Any] = ...,
level: Level | None = ...,
inplace: Literal[False] = ...,
errors: IgnoreRaise = ...
) -> DataFrame: ...
def drop(
labels: Hashable | Sequence[Hashable] | Index[Any],
*,
axis: Axis = ...,
index: None = ...,
columns: None = ...,
level: Level | None = ...,
inplace: Literal[False] = ...,
errors: IgnoreRaise = ...
) -> DataFrame: ...
def drop(
labels: None = ...,
*,
axis: Axis = ...,
index: Hashable | Sequence[Hashable] | Index[Any] = ...,
columns: Hashable | Sequence[Hashable] | Index[Any],
level: Level | None = ...,
inplace: _bool = ...,
errors: IgnoreRaise = ...
) -> (DataFrame | None): ...
def drop(
labels: None = ...,
*,
axis: Axis = ...,
index: Hashable | Sequence[Hashable] | Index[Any],
columns: Hashable | Sequence[Hashable] | Index[Any] = ...,
level: Level | None = ...,
inplace: _bool = ...,
errors: IgnoreRaise = ...
) -> (DataFrame | None): ...
def drop(
labels: Hashable | Sequence[Hashable] | Index[Any],
*,
axis: Axis = ...,
index: None = ...,
columns: None = ...,
level: Level | None = ...,
inplace: _bool = ...,
errors: IgnoreRaise = ...
) -> (DataFrame | None): ... drop function supports this many combination of types during operations. All the functions are same. Documentation is less descriptive about this thing. |
yes and no. The type declarations for any of
The docs currently say "single label or list-like" for those 3. A But at runtime, a |
In the specific case of |
Pandas version checks
main
hereLocation of the documentation
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.drop.html
Documentation problem
The arguments
labels
,index
andcolumns
are documented as "single label or list-like". But a set is accepted:The pandas source declaration in the typing declarations does not allow a set to be passed.
Suggested fix for documentation
Unclear.
Either we update the docs to say a set is allowed (and update the internal types), OR we add a check to see if a set is passed and raise an exception.
First raised as a
pandas-stubs
issue in pandas-dev/pandas-stubs#1008The text was updated successfully, but these errors were encountered: