Skip to content

ERR: DataFrame.fillna with non-unique mapping #36608

Open
@dsaxton

Description

@dsaxton
  • 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.

import numpy as np
import pandas as pd

df = pd.DataFrame({"a": [1.0, np.nan]})
s = pd.Series([0.0, 2.0], index=["a", "a"])
df.fillna(s)  # works silently on master or 1.1.2
#      a
# 0  1.0
# 1  0.0

Problem description

DataFrame.fillna using a Series with a duplicated index is potentially ambiguous, but the filling works silently (apparently using the first value).

Expected Output

Maybe a warning that the operation is ambiguous?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolatereplacereplace method

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions