However I found several similar questions/answers, none demonstrated a "simple" manner to order a pandas dataframe by groups of categories and minimum value like window partitions. The image represents pretty well the goal.
data = {
'Section': ['A', 'C', 'C', 'B', 'A', 'D', 'B', 'D'],
'Content': [3, 5, 2, 3, 1, 1, 0, 2]
}
df_initial = pd.DataFrame(data)
data = {
'Section': ['A', 'B', 'C', 'D', 'A', 'B', 'C', 'D'],
'Content': [1, 0, 2, 1, 3, 3, 5, 2]
}
df_sorted = pd.DataFrame(data)
This example was the nearest one I found by keeping the whole group together
Ranking order per group in Pandas
Cheers