-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
Open
Labels
BugCopy / view semanticsNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team member
Description
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
pd.options.mode.copy_on_write = True
df = pd.DataFrame(data={'A' : [1, 2],'B' : ['b', 'i like pandas'],})
df["Name"] = "I Have a Name"
df['Name2'] = 'i like pandas'
df.replace("i like pandas", "i like arrow")
df.replace(np.nan, None) # works
replace_mappings = {
pd.NA: None,
pd.NaT: None,
np.nan: None # Issue Type
}
df.replace(replace_mappings) # fails
Issue Description
When using DataFrame.replace and trying to replace np.nan value when in a dictionary, it raises an error. A standard replace(np.nan, None) will work though.
The error raised:
builtins.ValueError: <weakref at 0x0000023B896B2840; to 'ExtensionBlock' at 0x0000023B896A26F0> is not in list
Expected Behavior
The expected behavior is that the replace to not error out.
Installed Versions
This is reproducible in the v3 development release as of 10/22/25 and with the current public release. I tested in multiple versions
Metadata
Metadata
Assignees
Labels
BugCopy / view semanticsNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team member