I have a dataframe that looks like this:
df = pd.DataFrame({'animals': [None, 'cat', 'dog', None, 'hippo', 'elephant']})
The column animals has two None values.
I want to replace the first missing value with one value and the second missing value with another value.
The code I have so far replaces only for the first missing value. The second missing value is not updated.
new_df = df.animals.fillna(pd.Series(['unknown1', 'unknown2'])
new_df
0 unknown1
1 cat
2 dog
3 NaN
4 hippo
5 elephant
Name: animals, dtype: object
I expected that value for index 3 to be equal to unknown2.
How can I get this to work so that I can replace the missing values in a given column with a pandas series of missing values with a length equal to the number of missing values in that column?