How to find which columns contain any NaN value in Pandas dataframe

前端 未结 8 1720
醉酒成梦
醉酒成梦 2020-11-28 02:17

Given a pandas dataframe containing possible NaN values scattered here and there:

Question: How do I determine which columns contain NaN values? In

8条回答
  •  感情败类
    2020-11-28 02:50

    i use these three lines of code to print out the column names which contain at least one null value:

    for column in dataframe:
        if dataframe[column].isnull().any():
           print('{0} has {1} null values'.format(column, dataframe[column].isnull().sum()))
    

提交回复
热议问题