I am trying to remove 'nan' from a list, but it is refusing to go. I have tried both np.nan and 'nan'.
This is my code:
ztt = []
for i in z:
if i != 'nan':
ztt.append(i)
ztt
or:
ztt = []
for i in z:
if i != np.nan:
ztt.append(i)
ztt
I am still getting the output:
[[46.0, 34.0, 32.0, 40.0, 34.0, 29.0, 38.0, 39.0, 45.0, 32.0, 28.0, 43.0],
[32.0, 30.0, 67.0, 66.0, 28.0, 19.0, 39.0, 32.0, 51.0, 28.0, 20.0, 36.0],
[29.0, 24.0, 37.0, 31.0, 32.0, 34.0, 28.0, 31.0, 28.0, 33.0, 28.0, 39.0],
[27.0, 29.0, 35.0, nan, nan, nan, nan, nan, nan, nan, nan, nan]]
Anyone know what is going wrong?
for i in z:
if not math.isnan(i):
ztt.append(i)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With