encountered a problem and simplified it.
has a dataframe
df = pd.DataFrame([["a", 1, "c"], ["a", 3, "a"], ["a", 2, "b"],
["c", 3, "a"], ["c", 2, "b"], ["c", 1, "c"],
["b", 2, "b"], ["b", 3, "a"], ["b",1, "c"]], columns=["A", "B", "C"])
AB