df = pd.DataFrame({'A':[0,0,1], 'B':[0,1,0]})
print(df.sample(n=1, random_state=0, weights='B'))
If I set weights=['A','B']
, I get ValueError: could not convert string to float: 'A'
.
Is there any way around this to weight the sample based on both columns?
Aucun commentaire:
Enregistrer un commentaire