Pandas - Delete Rows with only NaN values

前端 未结 2 1026
日久生厌
日久生厌 2021-02-05 13:54

I have a DataFrame containing many NaN values. I want to delete rows that contain too many NaN values; specifically: 7 or more.

I tried using the dr

2条回答
  •  没有蜡笔的小新
    2021-02-05 14:13

    The optional thresh argument of df.dropna lets you give it the minimum number of non-NA values in order to keep the row.

    df.dropna(thresh=df.shape[1]-7)
    

提交回复
热议问题