0
我有一個數據幀象下面這樣:轉換一個多指標大熊貓數據幀以單一指標
i_id q_id
month category_bucket
Aug Algebra Tutoring 187 64
Balloon Artistry 459 401
Carpet Installation or Replacement 427 243
Dance Lessons 181 46
Landscaping 166 60
Others 9344 4987
Tennis Instruction 161 61
Tree and Shrub Service 383 269
Wedding Photography 161 49
Window Repair 140 80
Wiring 439 206
July Algebra Tutoring 555 222
Balloon Artistry 229 202
Carpet Installation or Replacement 140 106
Dance Lessons 354 115
Landscaping 511 243
Others 9019 4470
Tennis Instruction 613 324
Tree and Shrub Service 130 100
Wedding Photography 425 191
Window Repair 444 282
Wiring 154 98
這是一個與月份和類別剷鬥指數多指標的數據幀。和i_id,q_id欄目
我通過一個正常的數據幀上做了GROUPBY操作像下面
invites_combined.groupby(['month', 'category_bucket'])[["i_id","q_id"]].count()
我基本上要一個數據幀在那裏我有4列,每列2 i_id,Q-得到這個這兩個月的ID和category_bucket的一列。所以基本上將上面的多索引數據幀轉換爲單索引,以便我可以訪問這些值。
目前我很難訪問特定月份和類別值的i_id,q_id值。
如果您覺得有一種更簡單的方法來訪問每個類別和月份的i_id和q_id值,而無需轉換爲單個索引,那也可以。
雖然單個索引會更容易循環到每個月份和類別組合的每個值中。
就是爽。不知道。謝謝一堆。順便說一句,我們如何訪問多索引數據框中的值和索引? – Baktaawar