-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Description
In [2]: a = pandas.Series(['a', nan, 'b'])
In [3]: a == 'a'
Out[3]:
0 True
1 NaN
2 False
There is a NaN in Out[3]. This can't be the desired result because of the following error:
In [4]: b = pandas.Series(['a', 'b', 'c'])
In [5]: (a == 'a') & (b == 'a')
ValueError Traceback (most recent call last)
/home/dong/ in ()
----> 1 (a == 'a') & (b == 'a')
/home/dong/.virtualenv/src/pandas/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):
/home/dong/.virtualenv/src/pandas/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)
/home/dong/.virtualenv/src/pandas/pandas/_tseries.so in pandas._tseries.vec_binop (pandas/src/tseries.c:9302)()
ValueError: Does not understand character buffer dtype format string ('?')
BTW for series of dtype float there is no such problem:
In [6]: c = pandas.Series([1.0, nan, 3.0])
In [7]: c == 1
Out[7]:
0 True
1 False
2 False