-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: add NDFrame.select_str #27340
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
ENH: add NDFrame.select_str #27340
Conversation
Hello @topper-123! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2019-07-11 20:38:22 UTC |
8857c97
to
c243435
Compare
d5830b1
to
e4345ab
Compare
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.
Hmm not sure on the direction - so the original point was to implement this functionality into select right?
|
||
Parameters | ||
---------- | ||
startswith: str, optional |
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.
Can we not just boil the signature down to regex
?
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.
Yeah, startswith and endswith are not cardinal points for me, just thought they are often used, so nicer for people who don't want/know how to use regexes.
e4345ab
to
4ed0630
Compare
return matcher.search(x) is not None | ||
|
||
mapped = labels.map(f) | ||
return self.loc(axis=axis)[mapped] |
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.
so I would instead implement
df.loc(regex=)[....]
as an api, which turns the indexers into regexes.
Closing in favor of #27363 |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Adds a method
select_str
to supplementselect_dtypes
. This PR is intended to be followed by a PR that deprecateNDFrame.filter
.I miss the most having a string focused axis-filtering method, and is
NDFrame.filter
a bit unfocused and badly named IMO. I think usage of parameteritems
inNDFrame.filter
can just be replaced by recommendingNDFrame.__getitem__
and parameterlike
is less useful thanstartswith
andendswith
(is less precise). So this is not a 100 % replacement forNDFrame.filter
, but intends to make something that is more useful (IMO, of course).This is not fully tested and need a whatsnew etc. but I would like to get some response before I go further.