【发布时间】:2016-02-24 16:38:22
【问题描述】:
import pandas.io.data as web
import datetime
import matplotlib.pyplot as plt
start = datetime.datetime.strptime('2/10/2016', '%m/%d/%Y')
end = datetime.datetime.strptime('2/24/2016', '%m/%d/%Y')
f = web.DataReader(['GOOG','AAPL'], 'yahoo', start, end)
#print 'Volume'
wha = f[['Adj Close']] #pick out Adj Close
x=wha[0,:]
print x.shape
ax = f['Adj Close'].plot(grid=True, fontsize=10, rot=45.)
ax.set_ylabel('Adjusted Closing Price ($)')
plt.legend(loc='upper center', ncol=2, bbox_to_anchor=(0.5,1.1), shadow=True, fancybox=True, prop={'size':10})
#plt.show()
正如您在上面看到的,我试图挑选出个别股票价格的数值来进行数据操作。
与
#print wha[1,:]
x=wha[0,:]
print x.shape
我可以将其简化为 9x2 矩阵,其中您有两列用于 GOOG 和 AAPL,每列有 9 个价格。
我试过了
print type(x)
看看是不是
<class 'pandas.core.frame.DataFrame'>
通过
wha2=x.values.tolist()
我能够挑选出股票价格。
我现在有没有一种简单的方法来绘制一只股票的价格(例如单独的 AAPL)与日期?
【问题讨论】:
标签: python python-2.7 pandas anaconda