pandas データフレームを使用して Python にロードする一連のデータがあります。私がやりたいのは、すべてを 1 つではなく、独自のフレーム内のすべての要素のプロットを出力するループを作成することです。私のデータは、次のように構造化された Excel ファイルにあります。
Index | DATE | AMB CO 1 | AMB CO 2 |...|AMB CO_n | TOTAL
1 | 1/1/12| 14 | 33 |...| 236 | 1600
. | ... | ... | ... |...| ... | ...
. | ... | ... | ... |...| ... | ...
. | ... | ... | ... |...| ... | ...
n
これは私がこれまでにコードのために持っているものです:
import pandas as pd
import matplotlib.pyplot as plt
ambdf = pd.read_excel('Ambulance.xlsx',
sheetname='Sheet2', index_col=0, na_values=['NA'])
print type(ambdf)
print ambdf
print ambdf['EAS']
amb_plot = plt.plot(ambdf['EAS'], linewidth=2)
plt.title('EAS Ambulance Numbers')
plt.xlabel('Month')
plt.ylabel('Count of Deliveries')
print amb_plot
for i in ambdf:
print plt.plot(ambdf[i], linewidth = 2)
私はこのようなことを考えています:
for i in ambdf:
ambdf_plot = plt.plot(ambdf, linewidth = 2)
上記は私が望んでいたものではありませんでした.Pandas、MatplotLibなどに慣れていないことに起因していますが、いくつかのドキュメントを見ると、matplotlibは必要ないように見えます(質問2)
A) df のすべての列のデータのプロットを作成するにはどうすればよいですか? B) matplotlib を使用する必要がありますか、それとも pandas を使用してすべてを実行する必要がありますか?
ありがとうございました、