-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Description
Here's the code:
In [23]: d = DataFrame({'a': [np.nan, False], 'b': [True, True]})
In [24]: d['a'] | d['b']
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (1025, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (1036, 0))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/media/DATA/Code/Epidemic/<ipython-input-25-f18359aab663> in <module>()
----> 1 d['a'].fillna(False) | d['b']
/usr/lib/python2.7/site-packages/pandas/core/series.pyc in wrapper(self, other)
143 if isinstance(other, Series):
144 name = _maybe_match_name(self, other)
--> 145 return Series(na_op(self.values, other.values),
146 index=self.index, name=name)
147 elif isinstance(other, DataFrame):
/usr/lib/python2.7/site-packages/pandas/core/series.pyc in na_op(x, y)
132
133 if isinstance(y, np.ndarray):
--> 134 result = lib.vec_binop(x, y, op)
135 else:
136 result = lib.scalar_binop(x, y, op)
/usr/lib/python2.7/site-packages/pandas/_tseries.so in pandas._tseries.vec_binop (pandas/src/tseries.c:9600)()
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'double'
This seems to happen when performing any kind of boolean operation on a column containing a NaN. Calling .fillna() on it before the operation doesn't help (i.e. "d['a'].fillna(False) | d['b']" crashes as well). Also, "d['a'] & True" will fail too, but without the messages about "tokenizing input".