导出股票价格列表以示好



我想导入股票价格列表并使用python导出到excel。我可以附加价格清单,但无法导出。请帮忙。下面是我对Python不熟悉的代码。

import pandas as pd
import pandas_datareader.data as web
import datetime
import matplotlib 
import matplotlib.pyplot as plt
start = datetime.datetime(2015, 1, 1)
end = datetime.date.today()
stocklist=["ANDHRABANK.NS","HDFCBANK.NS","IDBI.NS","PNB.NS"]
prices=[]
for i in stocklist:
  f=web.DataReader(i, 'yahoo', start, end)
prices.append(f)
print prices

我得到以下结果。

[                 Open        High        Low      Close  Adj Close      Volume
Date                                                                          
2015-01-01  95.000000  100.949997  94.000000  96.449997  89.612679  17072046.0
2015-01-02  97.250000   98.050003  95.650002  96.250000  89.426872   4886258.0
2015-01-05  96.099998   96.800003  93.900002  94.150002  87.475739   3937461.0
2015-01-06  93.599998   93.599998  88.650002  89.349998  83.015999   4531779.0
2015-01-07  89.349998   90.500000  86.699997  88.500000  82.226265   5134680.0
2015-01-08  89.650002   91.750000  89.500000  91.000000  84.549042   3333586.0

现在,我想将收盘价导出并绘制到我的 Dropbox 中的现有 excel 文件中。

用于支持的坦克。

试试熊猫。卓越作家

In [1]: import pandas as pd
pd
In [2]: pd.ExcelWriter?
...
Init signature: pd.ExcelWriter(cls, path, engine=None, **kwargs)
Docstring:     
Class for writing DataFrame objects into excel sheets, default is to use
xlwt for xls, openpyxl for xlsx.  See DataFrame.to_excel for typical usage.
In [6]: pd.DataFrame.to_excel?
-----
If passing an existing ExcelWriter object, then the sheet will be added
to the existing workbook.  This can be used to save different
DataFrames to one workbook:
>>> writer = pd.ExcelWriter('output.xlsx')
>>> df1.to_excel(writer,'Sheet1')
>>> df2.to_excel(writer,'Sheet2')
>>> writer.save()

您仍然需要弄清楚保管箱部分

相关内容

  • 没有找到相关文章

最新更新