我正在创建从QUANDL获取财务数据的代码 问题是我无法按日期设置图表格式。 我上网搜索,发现必须使用matplotlib.dates库 在这里粘贴代码。 谁能帮助我?
我想以这种格式查看日期: 10-10-2018
import pandas as pd
import quandl
import datetime as dt
import numpy as np
#matplotlib
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.ticker as mticker
from matplotlib import style
start = dt.datetime(2018, 1, 1)
end = dt.date.today()
s = "AAPL"
#token = ""
#add authtoken = token
df = quandl.get("WIKI/" + s, start_date = start, end_date = end)
# df['10ma'] = df['Close'].rolling(10).mean().shift()
df['10ma'] = df['Close'].rolling(window = 10, min_periods= 0).mean()
df['20ma'] = df['Close'].rolling(window = 20, min_periods= 0).mean()
plt.show()
Open High Low ... Adj. Low Adj. Close Adj. Volume
Date ...
2018-01-02 170.16 172.30 169.26 ... 169.26 172.26 25048048.0
2018-01-03 172.53 174.55 171.96 ... 171.96 172.23 28819653.0
2018-01-04 172.54 173.47 172.08 ... 172.08 173.03 22211345.0
2018-01-05 173.44 175.37 173.05 ... 173.05 175.00 23016177.0
2018-01-08 174.35 175.61 173.93 ... 173.93 174.35 20134092.0
[5 rows x 12 columns]