Download data from FRED
Download data from FRED¶
import pandas as pd
import numpy as np
you need to get a FRED api key from here
the fredapi package is in the econ108 environment
from fredapi import Fred
fred = Fred(api_key="your_fred_api_key")
From FRED
Real Gross Domestic Product (GDPC1) Billions of Chained 2012 Dollars, Seasonally Adjusted Annual Rate
data = fred.get_series("GDPC1")
df = pd.DataFrame(data, columns=['GDPC1']).dropna(axis=0, how='any')
df.head()
GDPC1 | |
---|---|
1947-01-01 | 2034.450 |
1947-04-01 | 2029.024 |
1947-07-01 | 2024.834 |
1947-10-01 | 2056.508 |
1948-01-01 | 2087.442 |
Some more options…
data = fred.get_series_first_release('GDPC1')
data.tail()
date
2020-10-01 18780.325
2021-01-01 19087.568
2021-04-01 19358.176
2021-07-01 19465.195
2021-10-01 19805.962
Name: value, dtype: object
data = fred.get_series_latest_release('GDPC1')
data.tail()
2020-10-01 18767.778
2021-01-01 19055.655
2021-04-01 19368.310
2021-07-01 19478.893
2021-10-01 19810.572
dtype: float64
data=fred.get_series_as_of_date('GDP', '6/1/2014')
data
realtime_start | date | value | |
---|---|---|---|
0 | 1992-12-22 | 1946-01-01 | 199.7 |
1 | 1996-01-19 | 1946-01-01 | NaT |
2 | 1997-05-07 | 1946-01-01 | 210.4 |
3 | 1999-10-28 | 1946-01-01 | NaT |
4 | 1992-12-22 | 1946-04-01 | 207.7 |
... | ... | ... | ... |
2837 | 2014-01-30 | 2013-10-01 | 17102.5 |
2838 | 2014-02-28 | 2013-10-01 | 17080.7 |
2839 | 2014-03-27 | 2013-10-01 | 17089.6 |
2846 | 2014-04-30 | 2014-01-01 | 17149.6 |
2847 | 2014-05-29 | 2014-01-01 | 17101.3 |
2168 rows × 3 columns
fred.search('potential gdp').T
series id | GDPPOT | NGDPPOT | GDPC1CTMLR | NROU | NROUST | GDPC1MDLR | GDPC1RMLR | GDPC1RHLR | GDPC1CTLLR | GDPC1CTHLR | GDPC1RLLR |
---|---|---|---|---|---|---|---|---|---|---|---|
id | GDPPOT | NGDPPOT | GDPC1CTMLR | NROU | NROUST | GDPC1MDLR | GDPC1RMLR | GDPC1RHLR | GDPC1CTLLR | GDPC1CTHLR | GDPC1RLLR |
realtime_start | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 |
realtime_end | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 | 2022-02-28 00:00:00 |
title | Real Potential Gross Domestic Product | Nominal Potential Gross Domestic Product | Longer Run FOMC Summary of Economic Projection... | Noncyclical Rate of Unemployment | Natural Rate of Unemployment (Short-Term) (DIS... | Longer Run FOMC Summary of Economic Projection... | Longer Run FOMC Summary of Economic Projection... | Longer Run FOMC Summary of Economic Projection... | Longer Run FOMC Summary of Economic Projection... | Longer Run FOMC Summary of Economic Projection... | Longer Run FOMC Summary of Economic Projection... |
observation_start | 1949-01-01 00:00:00 | 1949-01-01 00:00:00 | 2009-02-18 00:00:00 | 1949-01-01 00:00:00 | 1949-01-01 00:00:00 | 2015-06-17 00:00:00 | 2009-02-18 00:00:00 | 2009-02-18 00:00:00 | 2009-02-18 00:00:00 | 2009-02-18 00:00:00 | 2009-02-18 00:00:00 |
observation_end | 2031-10-01 00:00:00 | 2031-10-01 00:00:00 | 2021-12-15 00:00:00 | 2031-10-01 00:00:00 | 2031-10-01 00:00:00 | 2021-12-15 00:00:00 | 2021-12-15 00:00:00 | 2021-12-15 00:00:00 | 2021-12-15 00:00:00 | 2021-12-15 00:00:00 | 2021-12-15 00:00:00 |
frequency | Quarterly | Quarterly | Not Applicable | Quarterly | Quarterly | Not Applicable | Not Applicable | Not Applicable | Not Applicable | Not Applicable | Not Applicable |
frequency_short | Q | Q | NA | Q | Q | NA | NA | NA | NA | NA | NA |
units | Billions of Chained 2012 Dollars | Billions of Dollars | Fourth Quarter to Fourth Quarter Percent Change | Percent | Percent | Fourth Quarter to Fourth Quarter Percent Change | Fourth Quarter to Fourth Quarter Percent Change | Fourth Quarter to Fourth Quarter Percent Change | Fourth Quarter to Fourth Quarter Percent Change | Fourth Quarter to Fourth Quarter Percent Change | Fourth Quarter to Fourth Quarter Percent Change |
units_short | Bil. of Chn. 2012 $ | Bil. of $ | Fourth Qtr. to Fourth Qtr. % Chg. | % | % | Fourth Qtr. to Fourth Qtr. % Chg. | Fourth Qtr. to Fourth Qtr. % Chg. | Fourth Qtr. to Fourth Qtr. % Chg. | Fourth Qtr. to Fourth Qtr. % Chg. | Fourth Qtr. to Fourth Qtr. % Chg. | Fourth Qtr. to Fourth Qtr. % Chg. |
seasonal_adjustment | Not Seasonally Adjusted | Not Seasonally Adjusted | Not Seasonally Adjusted | Not Seasonally Adjusted | Not Seasonally Adjusted | Not Seasonally Adjusted | Not Seasonally Adjusted | Not Seasonally Adjusted | Not Seasonally Adjusted | Not Seasonally Adjusted | Not Seasonally Adjusted |
seasonal_adjustment_short | NSA | NSA | NSA | NSA | NSA | NSA | NSA | NSA | NSA | NSA | NSA |
last_updated | 2021-07-01 17:45:02-05:00 | 2021-07-01 17:45:02-05:00 | 2021-12-15 14:08:07-06:00 | 2021-02-01 14:37:05-06:00 | 2021-02-01 14:37:07-06:00 | 2021-12-15 14:08:15-06:00 | 2021-12-15 14:08:34-06:00 | 2021-12-15 14:08:16-06:00 | 2021-12-15 14:08:39-06:00 | 2021-12-15 14:08:38-06:00 | 2021-12-15 14:08:39-06:00 |
popularity | 72 | 58 | 27 | 71 | 60 | 14 | 7 | 7 | 3 | 2 | 2 |
notes | Real potential GDP is the CBO’s estimate of th... | None | The longer-run projections are the rates of gr... | Starting with the July, 2021 report: An Update... | This series last appeared in the February, 202... | The longer-run projections are the rates of gr... | The longer-run projections are the rates of gr... | The longer-run projections are the rates of gr... | The longer-run projections are the rates of gr... | The longer-run projections are the rates of gr... | The longer-run projections are the rates of gr... |