BUG: df.combine_first
duplicates rows for nan index values
#39881
Labels
good first issue
Indexing
Related to indexing on series/frames, not to indexes themselves
Missing-data
np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
MultiIndex
Needs Tests
Unit test(s) needed to prevent regressions
Milestone
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(the issue sounds familiar, but I couldn't find it anywhere...)
(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
When combining two DataFrames with overlapping indices, the indices, which contain
nan
values but are otherwise identical, are duplicated.The problem doesn't occur when the
nan
values are substituted with say-1
.Expected Output
It is expected that
combine_first
detects that the index[1, NaN]
exists in both dataframes and thus does not duplicate this row in the resulting dataframe.Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 7d32926
python : 3.8.7.final.0
python-bits : 64
OS : Darwin
OS-release : 19.6.0
Version : Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST 2021; root:xnu-6153.141.16~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_AU.UTF-8
LOCALE : en_AU.UTF-8
pandas : 1.2.2
numpy : 1.19.4
pytz : 2020.4
dateutil : 2.8.1
pip : 20.2.3
setuptools : 46.4.0
Cython : 0.29.21
pytest : 5.1.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 0.9.6
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.3 (dt dec pq3 ext lo64)
jinja2 : 2.11.2
IPython : 7.16.1
pandas_datareader: None
bs4 : None
bottleneck : 1.3.1
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.0
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.5
pandas_gbq : None
pyarrow : 1.0.1
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.12
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: