从nsepy导入numpy作为np导入matplotlib.pyplot作为plt从nsepy导入get_history导入日期时间( dt %matplotlib inline = dt.datetime(2015,1,1) end = dt.datetime.today() infy =get_history(符号=‘INFY’,start = start,end = end) infy.index = pd.to_datetime(infy.index) hdfc =get_history(符号=‘HDFC’,start = start,结束) hdfc.index = pd.to_datetime(hdfc.index)依赖=get_history(符号=‘依赖’,开始=开始,reliance.index = pd.to_datetime(reliance.index) wipro =get_history(符号= 'Wipro‘,start = start,end = end) wipro.index = pd.to_datetime(wipro.index) open_prices =pd.concat([Infy’‘Open’,Hdfc‘’Open‘,信实’开放‘,Wipro’‘Open’],轴= 1) open_prices.columns = 'Infy','Hdfc',‘信实’,‘Wipro’f,(ax1,ax2) = plt.subplots(1,2,sharey=True) axes0,地块(open_prices.index.year,open_prices.INFY) axes0,情节(open_prices.index.year,open_prices.HDB) axes1,0 plot(open_prices.index.year,open_prices.TTM) axes1,1 plot(open_prices.index.year,open_prices.HDB)axes1
空白图是coming.Please帮助.?
发布于 2019-10-15 08:42:48
下面的代码工作正常,我已经更改了以下内容
( a)轴应该是ax,b) DF列名是不正确的,c)任何尝试这个例子的人都需要安装lxml库
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from nsepy import get_history
import datetime as dt
start = dt.datetime(2015, 1, 1)
end = dt.datetime.today()
infy = get_history(symbol='INFY', start = start, end = end)
infy.index = pd.to_datetime(infy.index)
hdfc = get_history(symbol='HDFC', start = start, end = end)
hdfc.index = pd.to_datetime(hdfc.index)
reliance = get_history(symbol='RELIANCE', start = start, end = end)
reliance.index = pd.to_datetime(reliance.index)
wipro = get_history(symbol='WIPRO', start = start, end = end)
wipro.index = pd.to_datetime(wipro.index)
open_prices = pd.concat([infy['Open'], hdfc['Open'],reliance['Open'],
wipro['Open']], axis = 1)
open_prices.columns = ['Infy', 'Hdfc', 'Reliance', 'Wipro']
print(open_prices.columns)
ax=[]
f, ax = plt.subplots(2, 2, sharey=True)
ax[0,0].plot(open_prices.index.year,open_prices.Infy)
ax[1,0].plot(open_prices.index.year,open_prices.Hdfc)
ax[0,1].plot(open_prices.index.year,open_prices.Reliance)
ax[1,1].plot(open_prices.index.year,open_prices.Wipro)
plt.show()https://stackoverflow.com/questions/58387520
复制相似问题