-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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 18 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 |
---|---|---|
|
@@ -42,7 +42,7 @@ Bug fixes | |
|
||
Other | ||
~~~~~ | ||
- | ||
- :meth:`DataFrame.dropna` now accepts a single label as ``subset`` along with array-like. (:issue:`41021`) | ||
- | ||
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. Can you revert this change |
||
|
||
.. --------------------------------------------------------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5874,7 +5874,7 @@ def dropna( | |
axis: Axis = 0, | ||
how: str = "any", | ||
thresh=None, | ||
subset=None, | ||
subset: IndexLabel = None, | ||
inplace: bool = False, | ||
): | ||
""" | ||
|
@@ -5906,7 +5906,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 | ||
|
@@ -5990,6 +5990,8 @@ def dropna( | |
|
||
agg_obj = self | ||
if subset is not None: | ||
# subset needs to be list | ||
subset = com.maybe_make_list(subset) | ||
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. Looking at the implementation of maybe_make_list, this will only function correctly if the sequence is a list or tuple (all other sequences will be packed as a single element list). Seems to me we either need make the API more restrictive (lists and tuples only), or improve the implementation to handle generic sequences. 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. e.g.
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. Thanks, reverted back to using @jreback this means I am not using |
||
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.
This should be targeted for 1.4 since it's not a regression. Can go in enhancements there (we try to not use the Other section).