📜  groupby fillna ffill - Python 代码示例

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

代码示例2
df['three'] = df.groupby(['one','two'], sort=False)['three']
                .apply(lambda x: x.ffill().bfill())
print (df)
   one  two  three
0    1    1   10.0
1    1    1   10.0
2    1    1   10.0
3    1    2   20.0
4    1    2   20.0
5    1    2   20.0
6    1    3    NaN
7    1    3    NaN