Skip to content

ENH: add freq parameter to _BaseReader #199

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

Closed
wants to merge 4 commits into from

Conversation

kurtforrester
Copy link

@kurtforrester kurtforrester commented Apr 27, 2016

added freq paramter _BaseReader and updated def params to accomodate monthly frequency data from the World Bank database.

closes #198

added `freq` paramter `_BaseReader` and updated `def params` to accomodate monthly frequency data from the World Bank database.
@sinhrks
Copy link
Member

sinhrks commented Apr 28, 2016

Thanks, can you add tests?

@@ -42,13 +42,14 @@ class _BaseReader(object):
_chunk_size = 1024 * 1024
_format = 'string'

def __init__(self, symbols, start=None, end=None,
def __init__(self, symbols, start=None, end=None, freq=None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raise ValueError if freq is not None or "M"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be that the base datareader should accept all of the valid pandas/datetime freq strings ('H', 'M', 'Q', 'A',...) and the specific modules for wb or oecd etc should then determine what is suitable for the particular data source? For instance World Bank offers monthly data, quarterly data, and annual data for the various data sources.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to care values which is not implemented ATM from user's point of view. Also, pls move freq to WorldBankReader as other readers don't use it.

NOTE: Some other readers have interval kw which also accept frequency-like. It may better to use the same word but not sure as I'm not native English speaker.

@kurtforrester
Copy link
Author

I don't know how to write tests but I will learn. Can you (@sinhrks) point me to where they need to be, what one looks like and I will work out what I have to do?

@sinhrks
Copy link
Member

sinhrks commented Apr 28, 2016

…y and annual data from World Bank.

also added test for monthly and quarterly.
@kurtforrester
Copy link
Author

I have reversed changes I made to the base data reader class and bundled it all in the world bank reader. I have added two test, one for monthly data and one for quarterly. Both currently pass on my machine (Python 3.5.1 from Anaconda 2.5.0 (64 bit) - Windows). Let me know if there is anything else needing attention.

return {'date': '{0}M{1:02d}:{2}M{3:02d}'.format(self.start.year,
self.start.month, self.end.year, self.end.month),
'per_page': 25000, 'format': 'json'}
if self.freq == 'Q':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls use if-elif-else

Kurt Forrester added 2 commits April 28, 2016 16:04
@femtotrader
Copy link
Contributor

I like freq parameter name as it's similar to pandas.date_range parameter http://pandas.pydata.org/pandas-docs/stable/generated/pandas.date_range.html

but I'd convert freq (string) to Pandas DateOffset
http://stackoverflow.com/questions/27368265/convert-freq-string-to-dateoffset-in-pandas

what is your opinion about this @sinhrks ?

@sinhrks
Copy link
Member

sinhrks commented Apr 28, 2016

No opinion for DateOffset, because no benefit from conversion ATM.

@sinhrks
Copy link
Member

sinhrks commented Apr 28, 2016

Travis failure looks unrelated to the change. Let me check...

@femtotrader femtotrader changed the title #198 added freq parameter to _BaseReader Jul 23, 2016
@femtotrader femtotrader changed the title added freq parameter to _BaseReader add freq parameter to _BaseReader Jul 23, 2016
@femtotrader femtotrader changed the title add freq parameter to _BaseReader ENH: add freq parameter to _BaseReader Sep 8, 2016
@davidandreoletti
Copy link

davidandreoletti commented Dec 20, 2016

@sinhrks @femtotrader Any date for this PR be merged ? I actually need it :)

@sinhrks
Copy link
Member

sinhrks commented Dec 21, 2016

Sorry, should have noticed that test failure has been fixed in #204.

@kurtforrester can u rebase?

@bashtage
Copy link
Contributor

@kurtforrester is this still needed/useful?

@bashtage bashtage mentioned this pull request Jan 18, 2018
3 tasks
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

Successfully merging this pull request may close these issues.

World Bank datareader cannot retrive monthly data
5 participants