Description
Code Sample, a copy-pastable example if possible
1) This is okay:
~pd.Series([False, False, True, False], dtype=bool)
Out[76]:
0 True
1 True
2 False
3 True
dtype: bool
2) This looks like a problem:
~pd.Series([False, False, True, False], dtype=bool).shift(1).dropna()
1 -1
2 -1
3 -2
dtype: object
Problem description
.shift
and .dropna
are common pandas operations.
.shift(1) converts dtype from bool to object, so the bitwise operation is applied to each object (~False).
The output in the latter case is extremely surprising. It might be safer to raise an Exception rather than allow bitwise operations implemented on objects.
~pd.Series([1.0], dtype=object)
Expected Output
Exception!
Output of pd.show_versions()
pandas: 0.19.0
nose: 1.3.7
pip: 9.0.1
setuptools: 35.0.2
Cython: 0.25.1
numpy: 1.10.1
scipy: 0.16.0
statsmodels: 0.6.1
xarray: None
IPython: 5.3.0
sphinx: 1.2.2
patsy: 0.4.0
dateutil: 2.6.0
pytz: 2015.6
blosc: None
bottleneck: None
tables: 3.3.0
numexpr: 2.4.6
matplotlib: 2.0.1
openpyxl: 2.3.3
xlrd: 0.9.4
xlwt: None
xlsxwriter: 0.8.4
lxml: 3.5.0
bs4: 4.5.3
html5lib: 0.999999999
httplib2: 0.9.2
apiclient: 1.4.2
sqlalchemy: 1.0.8
pymysql: None
psycopg2: None
jinja2: 2.9.6
boto: 2.20.1
pandas_datareader: None