How do the DataFrame objects of Pandas group and sort and retain the order of the groups?

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"])

clipboard.png

AB

clipboard.png

Jun.15,2022

clipboard.png


, , A,A, ()
:


clipboard.png

clipboard.png

and the parameter by the order of list elements is the order by which column you sort first

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8d6dd-1158.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8d6dd-1158.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?