Edited several times to match SO standard
I have a DataFrame with 2 columns: id, label. And I also have generated labels for some of the ids, so I have a dictionary 'new_labels', which stores label values for some ids. What is the best way of filling these values into the DF?
import pandas as pd
df = pd.DataFrame({'id': ['A', 'B', 'C', 'D', 'E', 'F'],
'label': ['yes', 'no', None, None, None, 'yes']})
new_labels = {'D':'yes', 'E':'no'}
In [1]: df
Out[1]:
id label
0 A yes
1 B no
2 C None
3 D None
4 E None
5 F yes
And after inserting the new_labels I expect my df to change as such:
In [3]: df
Out[3]:
id label
0 A yes
1 B no
2 C None
3 D yes
4 E no
5 F yes