vendredi 26 octobre 2018

Python Randomly Select Rows Until Criteria is Met

I have a dataframe that has a few ID's and then a column for money like this,

Id1     Id2     Id3     Money
1       10      13      10000
2       15      12      12500
3       20      11      60000

I need a pythonic method to randomly select rows until I hit $80M in money. I'm assuming a while loop such as...

while sum(money) < 80000000:
    df.sample()




Aucun commentaire:

Enregistrer un commentaire