我有一个pandas groupby,它导致下面的一组(第三列是总观测值的百分比)。
我想将第二列按第三列排序,这样“ 0-20”组将从高中开始,然后是高中,然后是一些大学,等等,然后是“ 80-90”组将从学士学位开始,然后是研究生学位,等等。
换句话说,我想按第三列对每个income_name字段中的educ_name字段进行排序。但是,我不知道该怎么做。任何帮助将非常感激。
income_name educ_name
0-20 Assoc Degree 11.0
BA Degree 9.0
Graduate Degree 3.0
High school 33.0
No High School 26.0
Some College 17.0
20-40 Assoc Degree 13.0
BA Degree 13.0
Graduate Degree 5.0
High school 33.0
No High School 19.0
Some College 17.0
40-60 Assoc Degree 12.0
BA Degree 19.0
Graduate Degree 9.0
High school 30.0
No High School 11.0
Some College 19.0
60-80 Assoc Degree 14.0
BA Degree 27.0
Graduate Degree 15.0
High school 24.0
No High School 5.0
Some College 16.0
80-90 Assoc Degree 12.0
BA Degree 35.0
Graduate Degree 26.0
High school 13.0
No High School 2.0
Some College 12.0
90-100 Assoc Degree 6.0
BA Degree 39.0
Graduate Degree 39.0
High school 7.0
No High School 3.0
Some College 6.0