I have a Pandas DF called “DF”. I would like to sample data from the population in such a way that, given a occurrence count, N = 100 and column = "Type", I would like to print a total of 100 rows from that column in such a way that the distribution of occurrences of each type is equal.
| SNo | Type | Difficulty |
|---|---|---|
| 1 | Single | 5 |
| 2 | Single | 15 |
| 3 | Single | 4 |
| 4 | Multiple | 2 |
| 5 | Multiple | 14 |
| 6 | None | 7 |
| 7 | None | 4323 |
For instance, If I specify N = 3, the output must be :
| SNo | Type | Difficulty |
|---|---|---|
| 1 | Single | 5 |
| 3 | Multiple | 4 |
| 6 | None | 7 |
If for the number N, the occurrences of certain types do not meet the minimum split, I can randomly increase another count.
I am wondering on how to approach this programmatically. Thanks!