Find empty or NaN entry in Pandas Dataframe

前端 未结 8 2485
不思量自难忘°
不思量自难忘° 2020-12-05 04:17

I am trying to search through a Pandas Dataframe to find where it has a missing entry or a NaN entry.

Here is a dataframe that I am working with:

cl_         


        
8条回答
  •  广开言路
    2020-12-05 04:46

    Another opltion covering cases where there might be severar spaces is by using the isspace() python function.

    df[df.col_name.apply(lambda x:x.isspace() == False)] # will only return cases without empty spaces
    

    adding NaN values:

    df[(df.col_name.apply(lambda x:x.isspace() == False) & (~df.col_name.isna())] 
    

提交回复
热议问题