BUG: Unary minus raises for series with Int64Dtype · Issue #36063 · pandas-dev/pandas (original) (raw)
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of pandas.
- (optional) I have confirmed this bug exists on the master branch of pandas (commit 73c1d32)
Code Sample, a copy-pastable example
import pandas as pd pd.version '1.1.1' s = pd.Series([1, 2, 3], dtype="Int64") -s Traceback (most recent call last): File "...", line 1, in -s File ".../lib/python3.8/site-packages/pandas/core/generic.py", line 1297, in neg arr = operator.neg(values) TypeError: bad operand type for unary -: 'IntegerArray'
Problem description
I cannot negate series with Int64Dtype. This was possible in previous versions (but it returned object dtype).
Expected Output
>>> import pandas as pd
>>> pd.__version__
'1.0.5'
>>> s = pd.Series([1, 2, 3], dtype="Int64")
>>> -s
0 -1
1 -2
2 -3
dtype: object
Output of pd.show_versions()
INSTALLED VERSIONS
commit : f2ca0a2
python : 3.8.3.final.0
python-bits : 64
OS : Darwin
OS-release : 19.6.0
Version : Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.1
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 47.3.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 7.15.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None