You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
importpandasaspd# Outer merge on two "Int64" columns casts the joining column to "int64"df1=pd.DataFrame(dict(nr=[1,2])).astype("Int64")
df2=pd.DataFrame(dict(nr=[2,3])).astype("Int64")
pd.merge(df1, df2, on="nr", how="outer").dtypes# nr int64# dtype: object# Inner merge is OKpd.merge(df1, df2, on="nr", how="inner").dtypes# nr Int64# dtype: object# Left merge is OKpd.merge(df1, df2, on="nr", how="left").dtypes# nr Int64# dtype: object# Right merge also casts to "int64"pd.merge(df1, df2, on="nr", how="right").dtypes# nr int64# dtype: object
Problem description
"Int64" columns lose their data type and are converted to "int64" when used as joining column in an outer or right merge.
This does not seem to happen for inner and left merges.
Expected Output
"Int64" columns should retain their dtype during merge operations.
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.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Problem description
"Int64" columns lose their data type and are converted to "int64" when used as joining column in an outer or right merge.
This does not seem to happen for inner and left merges.
Expected Output
"Int64" columns should retain their dtype during merge operations.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 2cb9652
python : 3.8.6.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : German_Switzerland.1252
pandas : 1.2.4
numpy : 1.20.2
pytz : 2021.1
dateutil : 2.8.1
pip : 21.1
setuptools : 51.0.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.6 (dt dec pq3 ext lo64)
jinja2 : None
IPython : None
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 : 4.0.0
pyxlsb : None
s3fs : None
scipy : 1.6.3
sqlalchemy : 1.4.0b1
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: