图表月汇率

问题描述 投票:0回答:0

我从这个网站上获取数据https://www.federalreserve.gov/releases/H10/hist/dat96_ja.txt

我想制作一个折线图,显示 1997 年和 1998 年的平均月利率。

所以 x 轴将是 Jan 97, Feb 97, ....., Dec 98.

这就是我到目前为止所做的

import pandas as pd
usyen = pd.read_csv("usyen.csv")
usyen = usyen.iloc[6:]
usyen[['Date','Rate']] = usyen.Column1.str.split(expand=True)
usyen.reset_index(inplace=True)
usyen = usyen.drop(['Column1', 'Column2', 'index'], axis=1)
usyen

import matplotlib.pyplot as plt
import seaborn as sns

sns.set(style = 'whitegrid')
fig, ax = plt.subplots(figsize = (10,5))

x = usyen(usyen.Date == 1997, 1998)['Date']
y = usyen['Rate']

ax.plot(x,y)

ax.set_title('Yen/US Exchange Rate')
ax.set_xlabel('Year')
ax.set_ylabel('Rate')

我的问题是图表没有显示。 错误:“DataFrame”对象不可调用

提前谢谢你

python pandas matplotlib finance
© www.soinside.com 2019 - 2024. All rights reserved.