forward fill specific columns in pandas dataframe

前端 未结 4 694
一生所求
一生所求 2020-11-28 09:50

If I have a dataframe with multiple columns [\'x\', \'y\', \'z\'], how do I forward fill only one column \'x\'? Or a group of columns [\'x\',

4条回答
  •  情歌与酒
    2020-11-28 10:33

    Two columns can be ffill() simultaneously as given below:

    df1 = df[['X','Y']].ffill()
    

提交回复
热议问题