Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining two Series of dtype Int8 converts them to Int64 #31899

Open
MarcoGorelli opened this issue Feb 11, 2020 · 0 comments
Open

Combining two Series of dtype Int8 converts them to Int64 #31899

MarcoGorelli opened this issue Feb 11, 2020 · 0 comments
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations

Comments

@MarcoGorelli
Copy link
Member

MarcoGorelli commented Feb 11, 2020

Code Sample, a copy-pastable example if possible

>>> s1 = pd.Series([91, 92, pd.NA, 94], dtype='Int8')                                                       
>>> s2 = s1.copy()                                                                                          

>>> s1 + s2  # result looks correct!                                                                                                  
0     -74
1     -72
2    <NA>
3     -68
dtype: Int8

>>> s1.combine(s2, lambda x, y: x+y)  # dtype has changed!                                                       
0     -74
1     -72
2    <NA>
3     -68
dtype: Int64

Problem description

The dtype has changed.

Expected Output

0     -74
1     -72
2    <NA>
3     -68
dtype: Int8

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 87b149f41d305fefa2a22b379b915c33b24a6d60
python : 3.7.6.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-76-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 0.26.0.dev0+2024.g87b149f41
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 45.1.0.post20200119
Cython : 0.29.14
pytest : 5.3.5
hypothesis : 5.5.1
sphinx : 2.3.1
blosc : None
feather : None
xlsxwriter : 1.2.7
lxml.etree : 4.5.0
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : 7.12.0
pandas_datareader: None
bs4 : 4.8.2
bottleneck : 1.3.1
fastparquet : 0.3.3
gcsfs : None
lxml.etree : 4.5.0
matplotlib : 3.1.3
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.1
pandas_gbq : None
pyarrow : 0.16.0
pytables : None
pytest : 5.3.5
pyxlsb : None
s3fs : 0.4.0
scipy : 1.4.1
sqlalchemy : 1.3.13
tables : 3.6.1
tabulate : 0.8.6
xarray : 0.15.0
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.2.7
numba : 0.48.0

@MarcoGorelli MarcoGorelli changed the title Combining two Series of dtype Int8 converts them to Int64, even the result looks like it's expressed as if it were Int8 Combining two Series of dtype Int8 converts them to Int64 Feb 11, 2020
@MarcoGorelli MarcoGorelli added Dtype Conversions Unexpected or buggy dtype conversions Bug labels Feb 12, 2020
@mroeschke mroeschke added the Numeric Operations Arithmetic, Comparison, and Logical operations label Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants