Importing and Managing Financial Data in Python
Stefan Jansen
Instructor
matplotlib
seaborn.distplot()
ty10 = web.DataReader('DGS10', 'fred', date(1962, 1, 1))
ty10.info()
DatetimeIndex: 15754 entries, 1962-01-02 to 2022-05-20
Data columns (total 1 columns):
# Column Non-Null Count Dtype
-- ------ -------------- -----
0 DGS10 15083 non-null float64
ty10.describe()
DGS10
mean 6.291073
std 2.851161
min 1.370000
25% 4.190000
50% 6.040000
...
ty10.dropna(inplace=True) # Avoid creation of copy
ty10.plot(title='10-year Treasury'); plt.tight_layout()
import seaborn as sns
sns.distplot(ty10)
ax = sns.distplot(ty10)
ax.axvline(ty10['DGS10'].median(), color='black', ls='--')
Importing and Managing Financial Data in Python