pandas replace null values for a subset of columns

后端 未结 3 2020
無奈伤痛
無奈伤痛 2021-02-14 16:07

I have a data frame with many columns, say:

df:
name   salary  age   title
John      100   35    eng
Bill      200  NaN    adm
Lena      NaN   28    NaN
Jane             


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-14 16:36

    According to Pandas documentation in 23.3

    values = {'salary': -1, 'age': -1}
    df = df.fillna(value=values)
    

提交回复
热议问题