Looks like it's almost all in tests.series.test_operators.test_operators_bitwise
In particular, op(series, index) will always raise for op in [&, |, ^]. (Presumably also op(series, categorical), but I haven't looked at that closely.) I can fix this and add some basic tests for it, but the dtype logic in ops._bool_method_SERIES
doesn't make entirely clear what the desired behavior is, so some input will be needed to flesh them out more thoroughly.
Comment From: jreback
not real clear what u r asking here - can u show an example
Comment From: jbrockmendel
TL;DR: it is not clear what the pandas convention is for the desired behavior of these operations with dtypes including timedelta64/datetime64/datetime64[tz]/categorical/[extension?]
In some cases these ops are bool-like and in others they are bit-like, see how filler
is defined https://github.com/pandas-dev/pandas/blob/master/pandas/core/ops.py#L1100, roughly:
elif isinstance(other, ABCSeries):
name = com._maybe_match_name(self, other)
is_other_int_dtype = is_integer_dtype(other.dtype)
other = fill_int(other) if is_other_int_dtype else fill_bool(other)
filler = (fill_int if is_self_int_dtype and is_other_int_dtype
else fill_bool)
else:
# scalars, list, tuple, np.array
filler = (fill_int if is_self_int_dtype and
is_integer_dtype(np.asarray(other)) else fill_bool)
The error-catching in the nested function (https://github.com/pandas-dev/pandas/blob/master/pandas/core/ops.py#L1063) is about patching numpy's conventions with pandas conventions:
arr = np.random.randn(5) * 1000
i = arr.astype('i8')
b = arr.astype(bool)
f = arr.astype('f8')
i & b --> returns 0/1-values in a ndarray[int64]
i & f --> raises TypeError
b & f --> raises TypeError
pd.Series(i) & pd.Series(b) --> returns Series[bool]
pd.Series(i) & pd.Series(f) --> returns Series[bool]
pd.Series(b) & pd.Series(f) --> returns Series[bool]
AFAICT this was written without datetime64/datetime64[tz]/timedelta64/categorical being taken into account, so it is not obvious what the desired behavior is for these other dtypes.
Comment From: jbrockmendel
The main important piece here is the dt64/td64, so closing in favor of #19759