在python中如何对特定数据fill_value?

图片说明

例如在数据中,profit 和country 中均有空置,如何对profit 的空置填充为0, 而Country 不会改变

df = df.replace(np.nan, 0)

这样会把所有空置填充为0(包括不需要的Country),在groupby 后就会在country 多出一个0的分类(不需要)

df.profit.replace(np.nan,0,replace=True)

https://blog.csdn.net/Dontla/article/details/102969140