Skip to content Skip to sidebar Skip to footer

When Using Dataframes As Params For .fillna(), Is Identical Shape Required?

According to the Docs, you can use a Dataframe as the value parameter for .fillna() http://pandas.pydata.org/pandas-docs/dev/generated/pandas.DataFrame.fillna.html But does the dat

Solution 1:

A workaround for this could be to use a transform (rather than an aggregating) groupby method:

df1.fillna(df1.groupby(level=0).transform("mean"))

It's unclear to me whether this is a bug in pandas, I recommend posting an issue on Github (it may be a nice feature)!

Post a Comment for "When Using Dataframes As Params For .fillna(), Is Identical Shape Required?"