DataFrame#where broken in latest 0.16.1 release #10218

Closed
dunpealer opened this Issue May 27, 2015 · 1 comment

Comments

Projects
None yet
2 participants

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"
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 added this to the Next Major Release milestone May 27, 2015

@jreback jreback modified the milestone: 0.16.2, Next Major Release, 0.17.0 Jun 5, 2015

jreback closed this in #10283 Aug 26, 2015

@jreback jreback added a commit that referenced this issue Aug 26, 2015

@jreback jreback Merge pull request #10283 from mortada/df_where
BUG: DataFrame.where does not handle Series slice correctly (#10218)
b55ca5c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment