I am trying to get the Adj Close prices from Yahoo Finance into a DataFrame. I have all the stocks I want but I am not able to sort on date.
stocks = [\'ORCL
Date is in the index values.
To get it into a column value, you should just use:
dataframe.reset_index(inplace=True,drop=False)
Then you can use
dataframe['Date']
because "Date" will now be one of the keys in your columns of the dataframe.
The sub-package pandas.io.data is removed from the latest pandas package and it is available to install separately as pandas-datareader
use git to install the package. in the linux terminal:
git clone https://github.com/pydata/pandas-datareader.git
cd pandas-datareader
python setup.py install
now you can use import pandas_datareader
to your python script for Remote data Access.
For more information Use this link to visit the latest documentation
f
is a Panel
You can get a DataFrame
and reset index (Date) using:
f.loc['Adj Close',:,:].reset_index()
but I'm not sure reset_index()
is very useful as you can get Date using
f.loc['Adj Close',:,:].index
You might have a look at http://pandas.pydata.org/pandas-docs/stable/indexing.html#different-choices-for-indexing about indexing
print(dataFrame.index[0])
2014-01-02 00:00:00
import pandas_datareader.data as web
import datetime
start = datetime.datetime(2015, 1, 1)
end = datetime.datetime(2016, 1, 1)
web.DataReader('GOOGL', 'yahoo', start, end)
This should do it.
import pandas as pd
from pandas.io.data import DataReader
symbols_list = ['ORCL', 'TSLA', 'IBM','YELP', 'MSFT']
d = {}
for ticker in symbols_list:
d[ticker] = DataReader(ticker, "yahoo", '2014-12-01')
pan = pd.Panel(d)
df1 = pan.minor_xs('Adj Close')
print(df1)
#df_percent_chg = df1.pct_change()