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

ENH: Adding '.' as an na_value for FRED. #3469

Merged
4 commits merged into from Apr 27, 2013
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

ENH: Better error message if a bad series name is passed to the

get_data_fred function.
  • Loading branch information...
TomAugspurger committed Apr 27, 2013
commit 51d2f7b32f82b8e5908e3f1b9b27530b08f096be
@@ -369,8 +369,15 @@ def get_data_fred(name=None, start=dt.datetime(2010, 1, 1),
data = read_csv(urllib.urlopen(url), index_col=0, parse_dates=True,
header=None, skiprows=1, names=["DATE", name],
na_values='.')
return data.truncate(start, end)

try:
return data.truncate(start, end)
except KeyError:
if data.ix[3].name[7:12] == 'Error':
raise Exception("Failed to get the data. "
"Check that {} is valid FRED "
"series.".format(name))
else:
raise

def get_data_famafrench(name, start=None, end=None):
start, end = _sanitize_dates(start, end)
@@ -74,6 +74,12 @@ def test_fred_parts(self):
result = web.get_data_fred("A09024USA144NNBR", start="1915").ix[:5]
assert (result.values == expected).all()

@slow
@network
def test_invalid_series(self):
name = "NOT A REAL SERIES"
self.assertRaises(Exception, web.get_data_fred, name)

if __name__ == '__main__':
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
exit=False)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.