pandas.read_excel()を使用して一連のExcelをDataFrameに読み込むスクリプトを作成しました。次に、これらのDataFrameはMultiIndexedDataFrameに変換されます。それらの構造は次のとおりです。
Customer1 Customer2 Customer3
Var1 Var2 Var3 Var1 Var2 Var3 Var1 Var2 Var3
0 1 6 4 6 2 5 7 6 6
1 3 5 0 1 5 4 1 6 5
2 5 7 3 6 1 4 7 5 1
. . . . . . . . . .
. . . . . . . . . .
100 1 6 4 6 2 4 7 6 6
次に、結合プロットと単数プロットの両方で、すべての「Var2」データをインデックスに対してプロットするにはどうすればよいですか?
使用DataFrame.xs
の選択のためにMultiIndex
とDataFrame.plot
:
print (df.xs('Var2', axis=1, level=1))
Customer1 Customer2 Customer3
0 6 2 6
1 5 5 6
2 7 1 5
100 6 2 6
df.xs('Var2', axis=1, level=1).plot()
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加