📜  掩码然后填充南# - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:01.131000             🧑  作者: Mango

代码示例1
a b c 
1 1 5.0
1 1 None
1 1 4.0
1 2 1.0
2 1 2.0
2 1 None

mask = (df['a']==1) & (df['b']==1)
mean = df.loc[mask, 'c'].mean()
df.loc[mask, 'c'] = df.loc[mask, 'c'].fillna(mean)