I want to import a list of stock prices and export to excel using python. I am able to append the list of prices but not able to export. Please help. Below is the code I am new to 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
I get the below result.
[ 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
Now I want to export and plot just the close price to an existing excel file in my Dropbox.
Tanks for the support.