我创建了一个open_prices
数据框。
使用相同的数据框,我必须创建open_yearly
,其中包括每年的平均开放价格。我还必须创建一个条形图,其股票名称在X轴上,价格在Y轴上。生成的图将具有多个条形图,用于比较2015年,2016年和2017年每只股票的价格。如何创建此类图?
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']
open_prices.head()