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

Allow .where to accept callable as condition #12533

sinhrks opened this Issue Mar 5, 2016 · 1 comment


None yet
2 participants

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

@jreback jreback referenced this issue Mar 5, 2016


API: chained reshaping ops #11485

2 of 2 tasks complete

This comment has been minimized.

Show comment
Hide comment

jreback Mar 5, 2016


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


jreback commented Mar 5, 2016

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

@jreback jreback added this to the 0.18.1 milestone Mar 5, 2016

@jreback jreback closed this in 7bbd031 Apr 29, 2016

nps added a commit to nps/pandas that referenced this issue May 17, 2016

ENH: Allow where/mask/Indexers to accept callable
closes pandas-dev#12533
closes pandas-dev#11485

Author: sinhrks <>

Closes pandas-dev#12539 from sinhrks/where and squashes the following commits:

6b5d618 [sinhrks] ENH: Allow .where to accept callable as condition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment