Function to replace NaN values in a dataframe with mean of the related column

后端 未结 3 382
甜味超标
甜味超标 2021-01-14 21:52

EDIT: This question is not a clone of pandas dataframe replace nan values with average of columns because I want to replace the value of each column with th

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-14 22:26

    To fill NaN of each column with its respective mean use:

    df.apply(lambda x: x.fillna(x.mean())) 
    

提交回复
热议问题