Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datareader doesn't download the desired samples as instructed #401

Closed
yongsua1989 opened this issue Sep 20, 2017 · 10 comments
Closed

Datareader doesn't download the desired samples as instructed #401

yongsua1989 opened this issue Sep 20, 2017 · 10 comments

Comments

@yongsua1989
Copy link

Hi, I would like to download only the stock price data for 3 months from Google Finance, but it keeps providing me data for one year. How do I slice the data I want or re-download the data I want?

from pandas_datareader import data
from datetime import datetime

cname = "KLSE:AXIATA" # Yahoo:6888.KL #Google: KLSE:AXIATA

wname = "google"

start= datetime(2017, 7, 15)

end=datetime(2017, 9, 15)

price = data.DataReader(cname, wname, start=start, end=end)["Close"].pct_change()

g

@yongsua1989
Copy link
Author

Anyway to slice the sample data? Is it possible instead of downloading whole year of data?

@rsvp
Copy link

rsvp commented Sep 20, 2017

The temporary problem with specifying dates is diagnosed here: #394 (comment)

Getting more data than you need should not be a major problem with pandas, e.g. use

 DataFrame.tail(n=64)

to approximate 3 months of daily data.

@i-frost
Copy link

i-frost commented Sep 23, 2017

I am doing this to filter for specific dates

df = df_reader.to_frame(filter_observations=False)

df[(df.index.get_level_values('Date')>='2017-09-21') & (df.index.get_level_values('Date')<='2017-09-22')]

@rsvp
Copy link

rsvp commented Sep 23, 2017

@i-frost as of v0.20.1 Panel is deprecated: https://pandas.pydata.org/pandas-docs/stable/whatsnew.html#whatsnew-0200-api-breaking-deprecate-panel and thus ".to_frame".

For contiguous dates, the easier expression would be: df['2017-09-21':'2017-09-22'] which relies on index slicing.

@i-frost
Copy link

i-frost commented Sep 25, 2017

Hey @rsvp, I am getting a Panel back from the reader call should it be a MultiIndex instead?

pd.version
'0.20.3'

df_reader = web.DataReader(['III'], 'google', (2017, 9, 23), (2017, 9, 23))
df_reader
<class 'pandas.core.panel.Panel'>

@HJ1nitj
Copy link

HJ1nitj commented Feb 1, 2018

Hi,
I am getting this 'ImmediateDeprecationError(DEP_ERROR_MSG.format('Yahoo Daily'))' while fetching the financial data from yahoo.

data=web.DataReader(stocks, data_source='yahoo', start=start_date, end=end_date)['Adj Close']

please help me with this issue.

@bashtage
Copy link
Contributor

bashtage commented Feb 1, 2018

This is not fixable. Yahoo is totally broken until someone figures out a way to rewrite it from scratch using a different method.

@bashtage bashtage closed this as completed Feb 1, 2018
@HJ1nitj
Copy link

HJ1nitj commented Feb 1, 2018

So can you please suggest some alternative?

@bashtage
Copy link
Contributor

bashtage commented Feb 1, 2018

You can manually download data from Yahoo in the browser. Or you could see if the data you need is available from one of the other sources (e.g., Morningstar, IEX, etc.). AFAIK there is no access to Yahoo from Python that works now.

@HJ1nitj
Copy link

HJ1nitj commented Feb 1, 2018

thanks sir...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants