pandas - Filter out rows with more than certain number of Nan -


In pandora dataframe, I would like to filter all the rows which have more than 2 nanows, basically i have 4 columns And I would like to put those rows, where at least 2 columns have limited value.

The following should be done < < p>

See what we are doing here, NaN rows, where the line contains 2 or more non NaN values.

Example:

 In  [25]: Import Pandas pd df = pd.DataFrame ({'a': [1,2, NaN, 4,5], 'B': [NaN, 2, NaN, 4,5], 'c': [1,2], nan, nan, nan], 'd': [1,2,3, nan, 5]}) DF Out [25]: ABCD 0 1NN 1 1 2 2 2 2 2 Na Nn N 3 3 4 4 NaN NaN 4 5 5 NaN 5 [5 Rows x 4 Column] [26]: df.dropna (thresh = 2) Out [26]: ABCD 0 1NAN 1 1 2 2 2 2 2 3 4 4 Nain Nain 4 5 5 nan 5 [4 rows x 4 column]   

Edit

This works for the above example but you should be aware that you have a number of columns Set the value to the value and set the value to thresh , I thought that basically it means the number of values ​​ NaN but it is actually the Maya Non NaN value number.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -