pandas
を使用して棒グラフを作成しようとしています。これは動作するはずです私の推測航法によってパンダで棒グラフを作成できません
import pandas as pd
indexes = ['Strongly agree', 'Agree', 'Neutral', 'Disagree', 'Strongly disagree']
df = pd.DataFrame({'Q7': [10, 11, 1, 0, 0]}, index=indexes)
df.plot.bar(indexes, df['Q7'].values)
が、私は私で投げ変なKeyError: 'Strongly agree'
を得る:私は、次のコードを持っています。なぜこれがうまくいかないのか分かりません。
'df.plot:このケースでは、
reset_index()
でカラムにindexes
を移動して、明示的に新しいindex
列を呼び出すことができます。をどちらのアプローチが正しいプロットを生成します'plot = bar = 'bar')'または 'df.plot.bar()' – Wen
'plot.bar'は同じものの別名ですか? –