I had a DataFrame
A B C
0 1 2 3
1 2 3 3
2 3 2 1
I needed to create a new column in a pandas DataFrame with 'yes' or 'no' randomly filling this column.
A B C NEW
0 1 2 3 yes
1 2 3 3 no
2 3 2 1 no
Using random.choice results in a column with the same result for every line
A B C NEW
0 1 2 3 no
1 2 3 3 no
2 3 2 1 no
I tried map, apply and applymap but there's a easier way to do.
Aucun commentaire:
Enregistrer un commentaire