-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Description
this fails because we are putmasking on a dtype=int ndarray
need to cast if this is the case (in series.where)
import pandas
df = pandas.DataFrame(index=[1,2])
df['test'] = [1,2]
df['test'][[True, False]] = pandas.Series([0],index=[1])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-9-7738933c68bb> in <module>()
----> 1 df['test'][[True,False]] = pandas.Series([0],index=[1])
/mnt/home/jreback/pandas/pandas/core/series.pyc in __setitem__(self, key, value)
677 if _is_bool_indexer(key):
678 key = self._check_bool_indexer(key)
--> 679 self.where(~key,value,inplace=True)
680 else:
681 self._set_with(key, value)
/mnt/home/jreback/pandas/pandas/core/series.pyc in where(self, cond, other, inplace)
630 raise ValueError('Length of replacements must equal series length')
631
--> 632 np.putmask(ser, ~cond, other)
633
634 return None if inplace else ser
TypeError: array cannot be safely cast to required type