I have this dataframe:
class number_of_lessons
0 C 15
1 A 5
2 B 8
3 E 11
4 N 12
5 F 5
6 D 10
I want to randomly select some rows from this table such as the sum of number of lessons in the new dataframe equals to 20.
As an example of output, we can have:
class number_of_lessons
0 C 15
1 A 5
or
class number_of_lessons
1 A 5
5 F 5
6 D 10
I tried too many things but nothing was correct. Any idea how to do it?