私はパンダでいくつかのクロス集計を作成しています:
a = np.array(['foo', 'foo', 'foo', 'bar', 'bar', 'foo', 'foo'], dtype=object)
b = np.array(['one', 'one', 'two', 'one', 'two', 'two', 'two'], dtype=object)
c = np.array(['dull', 'dull', 'dull', 'dull', 'dull', 'shiny', 'shiny'], dtype=object)
pd.crosstab(a, [b, c], rownames=['a'], colnames=['b', 'c'])
b     one   two       
c    dull  dull  shiny
a                     
bar     1     1      0
foo     2     1      2
しかし、私が実際に欲しいのは次のとおりです。
b     one        two       
c    dull  shiny dull  shiny
a                     
bar     1     0    1      0
foo     2     0    1      2
新しい列を追加してレベルを新しいMultiIndexとして設定することで回避策を見つけましたが、難しいようです...
MultiIndex を crosstabs 関数に渡して出力列を事前定義する方法はありますか?