ENH: column label filtering via regexes to work for numeric names by cyrusmaher · Pull Request #10384 · pandas-dev/pandas (original) (raw)
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Simple fix to allow regex filtering to work for numeric column labels, e.g. df.filter(regex="[12][34]")
closes #10506
Simple fix to allow regex filtering to work for numeric column labels, e.g. df.filter(regex="[12][34]")
Related to indexing on series/frames, not to indexes themselves
label
jreback changed the title
Update generic.py ENH: column label filtering via regexes to work for numeric names
For search(x) -> search(str(x))?
Any advice on what to add or where? I don't see any existing tests for this function...
look in pandas/tests/test_frame for test_filter
Thanks Jeff! Added the test. Let me know what you think...
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the issue number as a comment (this PR number since no associated issue)
add a not in whatsnew/0.17.0. Put in Other Enhancements section
What would this do in 0.16.2 (if you passed the regex), not fitler anything? or raise?
Done! In 0.16.2 re.search will raise if a column name is numeric...
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use double backticks here (and around DateFrame.filter)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the issue number (this PR number) onto the end (see how the other issues are done)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
say instead of raising ValueError
when you are all done, pls rebase/squash see contributing docs here
Simple fix to allow regex filtering to work for numeric column labels, e.g. df.filter(regex="[12][34]")
Add test for regex filter on numeric column names
Add release note
Add second regex test
I'm having trouble with squashing the commits. I don't have a ton of experience with git, so I'm not sure what to do next. Below is the message. Seems to have to do with a merge conflict in test_frame? Any advice?
error: could not apply ac90352... Add test for regex filter on numeric column names
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
The first commit's message is:
Fix regex filter for numeric columns
Simple fix to allow regex filtering to work for numeric column labels, e.g. df.filter(regex="[12][34]")
Add test for regex filter on numeric column names
Add release note
Add second regex test
This is the 2nd commit message:
Update generic.py
Simple fix to allow regex filtering to work for numeric column labels, e.g. df.filter(regex="[12][34]")
Simple fix to allow regex filtering to work for numeric column labels, e.g. df.filter(regex="[12][34]")
Hmm, when I rebase it detects conflicts, then I resolve them using git mergetool, and commit. Doesn't seem to change anything. When I run git merge master I get that everything is up-to-date. I'm probably missing something simple?
FYI, you don't normally need to add an issue if you just create a PR (like you did), but no biggie.