I am reading two columns of a csv file using pandas readcsv()
and then assigning the values to a dictionary. The columns contain strings of numbers and letters. Occasionally there are cases where a cell is empty. In my opinion, the value read to that dictionary entry should be None
but instead nan
is assigned. Surely None
is more descriptive of an empty cell as it has a null value, whereas nan
just says that the value read is not a number.
Is my understanding correct, what IS the difference between None
and nan
? Why is nan
assigned instead of None
?
Also, my dictionary check for any empty cells has been using numpy.isnan()
:
for k, v in my_dict.iteritems():
if np.isnan(v):
But this gives me an error saying that I cannot use this check for v
. I guess it is because an integer or float variable, not a string is meant to be used. If this is true, how can I check v
for an "empty cell"/nan
case?