I have a two column dataframe
id content
1 100
2 101
3
4 100
5
6 104
Now for missing values of content , I want to randomly assign content from the list of plausible values content_list=range(100,111)
So for id=3 and id=5 I want to populate content by any random value from content_list.
I used random.choice, but missing something here:
def f(list):
return random.choice(list)
if data.content.isnull():
data['content']=data['content'].map(f,content_list)
Aucun commentaire:
Enregistrer un commentaire