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 }})

@cyrusmaher

Simple fix to allow regex filtering to work for numeric column labels, e.g. df.filter(regex="[12][34]")

closes #10506

@cyrusmaher

Simple fix to allow regex filtering to work for numeric column labels, e.g. df.filter(regex="[12][34]")

@jreback

@jreback jreback added the Indexing

Related to indexing on series/frames, not to indexes themselves

label

Jun 18, 2015

@jreback jreback changed the titleUpdate generic.py ENH: column label filtering via regexes to work for numeric names

Jun 18, 2015

@cyrusmaher

For search(x) -> search(str(x))?

@cyrusmaher

Any advice on what to add or where? I don't see any existing tests for this function...

@jreback

look in pandas/tests/test_frame for test_filter

@cyrusmaher

@cyrusmaher

Thanks Jeff! Added the test. Let me know what you think...

jreback

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)

@jreback

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?

@cyrusmaher

@cyrusmaher

@cyrusmaher

Done! In 0.16.2 re.search will raise if a column name is numeric...

jreback

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

@jreback

when you are all done, pls rebase/squash see contributing docs here

@cyrusmaher

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

@cyrusmaher

@cyrusmaher

@cyrusmaher

@cyrusmaher

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".

@jreback

@cyrusmaher

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]")

@cyrusmaher

@cyrusmaher

@cyrusmaher

Simple fix to allow regex filtering to work for numeric column labels, e.g. df.filter(regex="[12][34]")

@cyrusmaher

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?

@jreback

FYI, you don't normally need to add an issue if you just create a PR (like you did), but no biggie.

@jreback

@jreback

Labels

2 participants

@cyrusmaher @jreback