〇出力グラフ
〇コード
from pandasdmx import Request
import matplotlib.pyplot as plt
oecd = Request('OECD')
countries="JPN"
data_response = oecd.data(resource_id='AEI_NUTRIENTS', key=countries + ".A11+A12+A13+A14+A19.NITROGEN/all?startTime=1990&endTime=2017")
oecd_data = data_response.data
df = data_response.write(oecd_data.series, parse_time=True)
df = df.unstack(level=0).to_frame()
df.columns=['Tonnes']
df = df.reset_index()
df = df[["INDICATOR", "TIME_PERIOD", "Tonnes"]]
df.set_index(["INDICATOR", "TIME_PERIOD"], inplace=True)
df = df.rename(index={'A11':'Total Cattle', 'A12':'Total Pigs', 'A13':'Total Sheep and Goats', 'A14':'Total Poultry', 'A19':'Total Other Livestock'})
ax = df.unstack(level=0).plot()
plt.xticks(rotation=90)
plt.legend(loc='best')
plt.show()
〇元データ
Agri-Environmental indicators: Nutrients
https://stats.oecd.org/Index.aspx?DataSetCode=AEI_NUTRIENTS
○関連情報
・Pandasdmxに関する他の記事はこちらを参照してください。
0 件のコメント:
コメントを投稿