Please explain how NaN is handled in pandas, because the following logic seems โbroken" to me, I tried various methods (shown below) to discard empty values.
My data frame, which I load from a CSV file using read.csv , has a comments column, which in most cases is empty.
The marked_results.comments column is as follows; everything else in the column is NaN, so pandas loads empty entries as NaN, so far so good:
0 VP 1 VP 2 VP 3 TEST 4 NaN 5 NaN ....
Now I'm trying to delete these entries, only this works:
marked_results.comments.isnull()
All this does not work:
marked_results.comments.dropna() gives only the same column, nothing is reset, it is confusing.marked_results.comments == NaN gives only a series of all False s. Nothing was NaNs ... confusing.- also
marked_results.comments == nan
I also tried:
comments_values = marked_results.comments.unique() array(['VP', 'TEST', nan], dtype=object)
python pandas nan dataframe
idoda
source share