Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use pandas.DataFrame.mask for NaN

I want to ignore NaN values in my selected dataframe columns when I want to normalize with sklearn.preprocessing.normalize. Column example:

0     12.0
1     12.0
2      3.0
3      NaN
4      3.0
5      3.0
6      NaN
7      NaN
8      3.0
9      3.0
10     3.0
11     4.0
12    10.0
like image 958
s900n Avatar asked Oct 23 '25 04:10

s900n


1 Answers

You can make use of function dropna(). It will return the same dataframe with rows containing NaN deleted.

>>> a.dropna()
     0  12.0
0    1    12
1    2     3
3    4     3
4    5     3
7    8     3
8    9     3
9   10     3
10  11     4
11  12    10
like image 176
Carles Mitjans Avatar answered Oct 25 '25 16:10

Carles Mitjans



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!