Skip to content

Allow .where to accept callable as condition #12533

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

Closed
sinhrks opened this issue Mar 5, 2016 · 1 comment
Closed

Allow .where to accept callable as condition #12533

sinhrks opened this issue Mar 5, 2016 · 1 comment
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@sinhrks
Copy link
Member

sinhrks commented Mar 5, 2016

Code Sample, a copy-pastable example if possible

Allow .where and .mask to accept callable as cond. This is useful if DataFrame is changed during method chaining.

df = pd.DataFrame(np.random.randn(2, 2))
df.where(lambda x: x > 0)
# currently raises ValueError

Expected Output

Should be the same as:

df.where(df > 0)
#           0         1
#0  0.689202       NaN
#1       NaN  0.261644
@sinhrks sinhrks added Indexing Related to indexing on series/frames, not to indexes themselves API Design labels Mar 5, 2016
@jreback
Copy link
Contributor

jreback commented Mar 5, 2016

yeah I link to the master issue for this #11485; .query, .where, and indexers should accept callables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants