python - Find Indexes of a List of DataFrame that have NaN Values - Pandas -


i have list of data frames in data frames have nan values. far can identify nan values single data frame using link.

how can find index of list data frame has nan values.

sample list of dffs,

[                     var1       var1   14.171250  13.593813 13.578317  13.595329 10.301850  13.580139 9.930217   nan 6.192517   13.561943 nan        13.565149 6.197983   13.572509,      var1       var2     2.456183  5.907528 5.052017  5.955731 5.960000  5.972480 8.039317  5.984608 7.559217  5.985348 6.933633  5.979438,   var1       var1   14.171250  23.593813 23.578317  23.595329 56.301850  23.580139 90.930217   22.365676 89.192517   33.561943 86.23654   53.565149 nan        13.572509,   ...] 

i need results in list indexes 0 , 2 have nan values.

so far tried this,

df_with_nan = [] df in dffs:     df_with_nan.append(df.columns[df.isnull().any()]) 

per above for loop column names, var1 , var2. however, need indexes of data frames when loop through it. or suggestion great.

you're there... use enumerate loop indices, , df.isnull().values.any() (faster df.isnull().any().max()) test:

df_with_nan = [] i, df in enumerate(dffs):     if df.isnull().values.any():         df_with_nan.append(i) 

granted, list comp shorter, go whatever prefer.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -