I have a large dataset with the columns 'group' and 'postcode'. An example of the df is given below:
Age
65+
16-25
16-25
26-39
40-64
65+
26-39
40-64
16-25
65+
I am trying to affect to each row value a random value with the code below
df['AGE'] = df['AGE'].replace({'65+': randint(65,100), '16-25': randint(16,25), '26-39': randint(26,39), '40-64': randint(40,64) })
But what I'm getting are four random values to each of these values: {'65+', '16-25', '26-39', '40-64'} like so :
Age
73
23
23
34
42
73
34
42
23
73
Can someone please help me figure out what am I doing wrong by correcting my code?
Aucun commentaire:
Enregistrer un commentaire