Pandas Fillna Mode

后端 未结 6 1280
借酒劲吻你
借酒劲吻你 2021-02-05 12:13

I have a data set in which there is a column known as Native Country which contain around 30000 records. Some are missing represented by NaN so I thoug

6条回答
  •  无人共我
    2021-02-05 12:23

    Just call first element of series:

    data['Native Country'].fillna(data['Native Country'].mode()[0], inplace=True)
    

    or you can do the same with assisgnment:

    data['Native Country'] = data['Native Country'].fillna(data['Native Country'].mode()[0])
    

提交回复
热议问题