Reputation: 8145
I have a dataframe called firstpart.
I'm trying to update the values in one column (Key), but only for rows in which another column (Zone) has no data.
I'm using this code, which doesn't work:
firstpart.ix[firstpart.Zone ==np.nan,"Key"] = "newvalue"
Neither does this:
firstpart.ix[firstpart.Zone =="","Key"] = "newvalue"
Using this syntax I'm able to update values in rows for which Zone has another value, but for some reason not if I try to select the rows in which it is blank.
What am I doing wrong?
Upvotes: 0
Views: 218
Reputation: 15718
firstpart.ix[firstpart.Zone.isnull()] = "newvalue"
You can't equate NaN to anything.
In [1]: NaN == NaN
Out[1]: False
You need special methods for that, and this is what .isnull() is about.
Upvotes: 1