lundi 14 septembre 2020

Distribution of Items in Dataframe into Randomized Groups with Values Cap

In the picture below, assume the table on the right is a pandas dataframe. I would like to randomly distribute each item in the dataframe between groups A, B, and C.

The rules are: (1) The number of squirrels in each group must not exceed the maximum number of squirrels. (2) If a country is listed twice (east and west coast), both entries must go into the same group.

The data is completely made up. The dataframe I'm working with is larger than this example. Dataframe in question




Aucun commentaire:

Enregistrer un commentaire