-2
我有以下的数据帧数据框中操纵和聚集
City Status q1 q2 Record
0 Austin Standard N Y Active
1 Dallas Standard N y Active
2 Orlando Standard N N Active
3 Orlando Ex Y Y Inactive
4 Orlando Standard N N Active
我试图操纵它看起来像这样:
Count %
All Cities 5 100.0%
Active 4 80%
Ex 1 20%
Standard 4 80%
Q1 = Y 1 20%
Q2 = Y 2 40%
Inactive 1 20%
我已经使出了一大块的代码,分别计算通过将每个df列分解为其组件状态(例如,q1yes的列,q1no的列等),然后递归填充数据框,但我觉得我必须缺少某些东西。
我还需要按照城市打破它,但我想寻求更多的帮助