Skip to content
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

DataFrame#where broken in latest 0.16.1 release #10218

Closed
dunpyl opened this issue May 27, 2015 · 1 comment · Fixed by #10283
Closed

DataFrame#where broken in latest 0.16.1 release #10218

dunpyl opened this issue May 27, 2015 · 1 comment · Fixed by #10283
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@dunpyl
Copy link

dunpyl commented May 27, 2015

Simple usecase of DataFrame#where fails on a freshly installed latest Pandas release:

In [1]: df = DataFrame([1, 2]); df
Out[1]: 
   0
0  1
1  2

In [2]: df.where(df[0]==1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-7b64bb424f7b> in <module>()
----> 1 df.where(df[0]==1)

/home/dunpeal/.env/lib/python3.4/site-packages/pandas/core/generic.py in where(self, cond, other, inplace, axis, level, try_cast, raise_on_error)
   3445 
   3446         if isinstance(cond, NDFrame):
-> 3447             cond = cond.reindex(**self._construct_axes_dict())
   3448         else:
   3449             if not hasattr(cond, 'shape'):

/home/dunpeal/.env/lib/python3.4/site-packages/pandas/core/series.py in reindex(self, index, **kwargs)
   2142     @Appender(generic._shared_docs['reindex'] % _shared_doc_kwargs)
   2143     def reindex(self, index=None, **kwargs):
-> 2144         return super(Series, self).reindex(index=index, **kwargs)
   2145 
   2146     @Appender(generic._shared_docs['fillna'] % _shared_doc_kwargs)

/home/dunpeal/.env/lib/python3.4/site-packages/pandas/core/generic.py in reindex(self, *args, **kwargs)
   1747         if kwargs:
   1748             raise TypeError('reindex() got an unexpected keyword '
-> 1749                     'argument "{0}"'.format(list(kwargs.keys())[0]))
   1750 
   1751         self._consolidate_inplace()

TypeError: reindex() got an unexpected keyword argument "columns"
@jreback
Copy link
Contributor

jreback commented May 27, 2015

use


In [2]: df.where(df[[0]]==1)
Out[2]: 
    0
0   1
1 NaN

In [3]: df[df[0]==1]
Out[3]: 
   0
0  1

will mark this as a bug in any event I don't think this worked previously.
pull-requests are welcome

@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves labels May 27, 2015
@jreback jreback added this to the Next Major Release milestone May 27, 2015
@jreback jreback modified the milestones: 0.16.2, Next Major Release, 0.17.0 Jun 5, 2015
jreback added a commit that referenced this issue Aug 26, 2015
BUG: DataFrame.where does not handle Series slice correctly (#10218)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 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