-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
ENH: check for string and convert to list in DataFrame.dropna subset argument #41022
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
Changes from 6 commits
6afcbcd
86d2cd8
03d3e0d
f7a1847
0326c7a
63a78ef
93fb0b3
103bd35
365c6c0
cace369
66d447d
7be5fe7
1dd0a64
56ef81e
ae633cf
4b905e5
c585c8f
1d5f208
2bf5ac3
9ea97ff
d09c6ba
c09d147
e95200b
df5ca75
17fe9bc
b471701
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,9 @@ | |
Hashable, | ||
Iterable, | ||
Iterator, | ||
Optional, | ||
Sequence, | ||
Union, | ||
cast, | ||
overload, | ||
) | ||
|
@@ -5803,7 +5805,7 @@ def dropna( | |
axis: Axis = 0, | ||
how: str = "any", | ||
thresh=None, | ||
subset=None, | ||
subset: Optional[Union[Hashable, Sequence[Hashable]]] = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you type using new syntax | for Union and | None for Optional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually saw we have an internal type for this if I'm not mistaken: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @simonjayhawkins would be the person to ask here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @simonjayhawkins any chance you can have a look? |
||
inplace: bool = False, | ||
): | ||
""" | ||
|
@@ -5835,7 +5837,7 @@ def dropna( | |
|
||
thresh : int, optional | ||
Require that many non-NA values. | ||
subset : array-like, optional | ||
subset : column label or sequence of labels, optional | ||
Labels along other axis to consider, e.g. if you are dropping rows | ||
these would be a list of columns to include. | ||
inplace : bool, default False | ||
|
@@ -5919,6 +5921,14 @@ def dropna( | |
|
||
agg_obj = self | ||
if subset is not None: | ||
if ( | ||
not np.iterable(subset) | ||
erfannariman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
or isinstance(subset, str) | ||
or isinstance(subset, tuple) | ||
and subset in self.columns | ||
): | ||
# subset needs to be list like | ||
subset = (subset,) | ||
ax = self._get_axis(agg_axis) | ||
indices = ax.get_indexer_for(subset) | ||
check = indices == -1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meaning your change, sorry if not clear