How to select a set of pandas rows, where the sum of each column is approximately the same or around a given number?
Suppose there is a dataframe of mxn like:
a b c d
0 19 13 14 19
1 13 6 6 10
2 2 16 12 26
3 8 2 9 27
4 16 6 10 22
5 6 14 14 26
6 18 8 8 22
7 8 11 7 18
8 16 12 12 23
9 14 19 5 11
How to randomly select a number of rows, that the sum of each column is approximately the same or around a given number?
Edit: As pointed out in the comment, it may be very hard to find a solution in case the standard deviation among columns is high, so it can be only an approximation rather than a fixel solution.
source https://stackoverflow.com/questions/70839882/how-to-select-a-set-of-pandas-rows-where-the-sum-of-each-column-is-approximatel
Comments
Post a Comment