How do I delete a whole row that contains "NaN" values using python code?

40 Views Asked by At

I understand that there have been already threads about deleting rows containing NaN in Python, but my question is a little bit different. I don't understand why it keeps producing this error using this code:

data = data.drop(data.index[0])

enter image description here

Also, could use the delete method as well? But I don't know how to do that one. I would imagine it goes something like this

delete data[0]

I have attached a picture of python outputting the excel data fine, but deleting the row containing NaN is driving me crazy! enter image description here

1

There are 1 best solutions below

0
On

enter image description hereI figured out my own question. Probably the first time ever on this site. Here is the correct code to use:

data.drop(data.index[0])