I have a Pandas DataFrame with a series containing dicts.
import pandas as pd
df = pd.DataFrame({
'c': [np.nan, 'N', np.nan, 'N'],
'd': [{'c':'C'}, np.nan, {'c':'C'}, np.nan]
})
I am attempting to fillna with:
df.fillna(np.where(df['d'].str['c'] == "C", "Y", "N"), inplace=True)
Traceback:
/Applications/Anaconda/anaconda3/lib/python3.9/site-packages/pandas/core/generic.py in fillna(self, value, method, axis, inplace, limit, downcast)
6501 elif isinstance(value, ABCDataFrame) and self.ndim == 2:
6502
-> 6503 new_data = self.where(self.notna(), value)._mgr
6504 else:
6505 raise ValueError(f"invalid fill value with a {type(value)}")
ValueError: invalid fill value with a <class 'numpy.ndarray'>