I have a df like this:
num1 num2
0 [2.0] 10
1 [3.0] 20
2 [4.0] 30
3 [5.0] 40
4 [6.0] 50
5 [nan] 60
6 [nan] 70
7 [10.0] 80
8 [nan] 90
9 [15.0] 100
num1
column contains arrays of floats. [nan]
is a numpy array containing a single np.NaN
.
I am converting this to integers via this:
df['num1'] = list(map(int, df['num1']))
If I just use this df:
num1 num2
0 [2.0] 10
1 [3.0] 20
2 [4.0] 30
3 [5.0] 40
4 [6.0] 50
This works when there are no [nan]
and I get:
num1 num2
0 2.0 10
1 3.0 20
2 4.0 30
3 5.0 40
4 6.0 50
But if I include the full df with [nan]
I get the error:
`ValueError: cannot convert float NaN to integer`
I tried doing:
df[df['num1'] != np.array(np.NaN)]
But this gave the error:
TypeError: len() of unsigned object
How can I get the desired output:
num1 num2
0 2.0 10
1 3.0 20
2 4.0 30
3 5.0 40
4 6.0 50
5 10.0 80
6 15.0 100