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

前端 未结 8 1733
醉酒成梦
醉酒成梦 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:35

    I had a problem where I had to many columns to visually inspect on the screen so a short list comp that filters and returns the offending columns is

    nan_cols = [i for i in df.columns if df[i].isnull().any()]
    

    if that's helpful to anyone

提交回复
热议问题