将股票价格列表导出到 excel

Export a list of stock prices to excel

我想导入股票价格列表并使用 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 文件。

感谢支持。

尝试pandas.ExcelWriter

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()

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