Skip to content

BUG: Series.combine_first incorrectly handles duplicate indices instead of raising ValueError #66009

Description

@Johnhi19

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
import numpy as np

s1 = pd.Series([1.0, np.nan, 3.0], index=[0, 0, 1])
s2 = pd.Series([10.0, 20.0, 30.0], index=[0, 0, 1])

res = s1.combine_first(s2)
print(res)

Issue Description

In this example, we have 2 Series with the same indexes. These indexes have duplicate labels and as of my understanding, reindexing on duplicate labels is not allowed. However, I get the following output on the current main branch:

0     1.0
0    20.0
1     3.0
dtype: float64

I know that this case is a special edge case so please tell me if you agree with me or not. I also have a possible solution for this issue.

Expected Behavior

I would expect the example to raise a ValueError:

ValueError: cannot reindex on an axis with duplicate labels

Installed Versions

Details

INSTALLED VERSIONS

commit : b9a5a83
python : 3.11.15
python-bits : 64
OS : Linux
OS-release : 6.1.0-37-amd64
Version : #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22)
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8

pandas : 3.1.0.dev0+1097.gb9a5a83175
numpy : 2.4.6
dateutil : 2.9.0.post0
pip : 24.0
Cython : 3.2.5
sphinx : 9.0.4
IPython : 9.14.1
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.15.0
bottleneck : 1.6.0
fastparquet : 2026.5.0
fsspec : 2026.6.0
html5lib : 1.1
hypothesis : 6.155.7
gcsfs : 2026.6.0
jinja2 : 3.1.6
lxml.etree : 6.1.1
matplotlib : 3.11.0
numba : 0.65.1
numexpr : 2.14.1
odfpy : None
openpyxl : 3.1.5
psycopg2 : 2.9.12
pymysql : 2.2.8
pyarrow : 23.0.1
pyiceberg : 0.11.1
pyreadstat : 1.3.5
pytest : 9.1.1
python-calamine : None
pytz : 2026.2
pyxlsb : 1.0.10
s3fs : 2026.6.0
scipy : 1.17.1
sqlalchemy : 2.0.51
tables : 3.11.1
tabulate : 0.10.0
xarray : 2026.4.0
xlrd : 2.0.2
xlsxwriter : 3.2.9
zstandard : 0.25.0
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugClosing CandidateMay be closeable, needs more eyeballsIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions