numpy - Pandas - Delete rows with two or more NaN values in dataframe -


i want delete column values contain many nan values; specifically: 2 or more. have dataframe column looks this. below column had 40 rows . want remove nan values 19th row (after 17.9 value).

avgws  0.12   1   2.04   3.01   3.99   5   6   7   7.99   9   10   10.98   11.99   13   13.93   14.99   15.98   nan   17.9   nan   nan   nan   nan   nan   nan   nan   nan   nan   nan   nan   nan   nan   nan   nan   nan   nan   nan   nan   nan   nan   

thanks

you can call isnull() on column, return series boolean values, cast int, true values become 1 , false becomes 0 , call cumsum(), filter df cumumlative sum less 2 equates point nan count becomes greater 2:

in [110]:  df[df['avgws'].isnull().astype(int).cumsum() < 2] out[110]:     avgws 0    0.12 1    1.00 2    2.04 3    3.01 4    3.99 5    5.00 6    6.00 7    7.00 8    7.99 9    9.00 10  10.00 11  10.98 12  11.99 13  13.00 14  13.93 15  14.99 16  15.98 17    nan 18  17.90 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -