I have a dataset with two columns: sID and sum_count. Now, I need to divide the sID into 5 groups with the requirement that: The sum of the sum_count column in each group should be as equal as possible (if perfect equality is not achievable, then as close as possible). The sIDs within each group should be merged into a single comma-separated string. For example, the original data format is as follows: sID sum_count A 10 B 5 C 8 D 12 The desired output would look something like: Group1: sID=A,C,E | sum_count_total=30 Group2: sID=B,D,F | sum_count_total=28 I have tried simple random grouping or sorting by sum_count and distributing them alternately, but the result has not been ideal. Are there more efficient algorithms or existing tools (like Python libraries or DolphinDB functions) that can achieve this task? Continue reading...