Examples of usage

Import modules needed

In addition to the modules of fredeco, matplotlib is imported because it will be used to quickly plot data retrieved from FRED® API. My API key is not provided, for the illustrations below. It is saved in the object my_fred_key.

[2]:
from fredeco.fredData import fred_series, fred_multi_series, explore
from fredeco.fredSearch import fred_list_series, fred_info_series, fred_search, fred_vintagedates
import matplotlib

Retrieve data

Below, data related to the US GDP are retrieved.

[10]:
df_one=fred_series(series='GDP',fred_api=my_fred_key)
df_one.tail(5)
[10]:
GDP
Dates
2019-01-01 21380.976
2020-01-01 21060.474
2021-01-01 23315.081
2022-01-01 25462.722
2023-01-01 NaN

Below data related to several indicators are retrieved.

[9]:
df_multi=fred_multi_series(series=['GDP','GDPCA'],fred_api=my_fred_key)
df_multi.tail(5)
[9]:
GDP GDPCA
Dates
2019-01-01 21380.976 19036.052
2020-01-01 21060.474 18509.143
2021-01-01 23315.081 19609.812
2022-01-01 25462.722 20014.128
2023-01-01 NaN NaN

Search for information

If a user want to look for indicators related to price index, fredeco allows to search for them as follows.

[32]:
fred_search(text='price index',fred_api=my_fred_key)
[32]:
id realtime_start realtime_end title observation_start observation_end frequency frequency_short units units_short seasonal_adjustment seasonal_adjustment_short last_updated popularity group_popularity notes
0 CPIAUCSL 2023-07-11 2023-07-11 Consumer Price Index for All Urban Consumers: ... 1947-01-01 2023-05-01 Monthly M Index 1982-1984=100 Index 1982-1984=100 Seasonally Adjusted SA 2023-06-13 07:44:03-05 94 94 The Consumer Price Index for All Urban Consume...
1 CPIAUCNS 2023-07-11 2023-07-11 Consumer Price Index for All Urban Consumers: ... 1913-01-01 2023-05-01 Monthly M Index 1982-1984=100 Index 1982-1984=100 Not Seasonally Adjusted NSA 2023-06-13 07:44:06-05 71 94 Handbook of Methods (https://www.bls.gov/opub/...
2 CSUSHPINSA 2023-07-11 2023-07-11 S&P/Case-Shiller U.S. National Home Price Index 1987-01-01 2023-04-01 Monthly M Index Jan 2000=100 Index Jan 2000=100 Not Seasonally Adjusted NSA 2023-06-27 08:13:02-05 90 92 For more information regarding the index, plea...
3 CUUS0000SA0 2023-07-11 2023-07-11 Consumer Price Index for All Urban Consumers: ... 1984-01-01 2022-07-01 Semiannual SA Index 1982-1984=100 Index 1982-1984=100 Not Seasonally Adjusted NSA 2023-01-12 07:38:17-06 43 94 NaN
4 CSUSHPISA 2023-07-11 2023-07-11 S&P/Case-Shiller U.S. National Home Price Index 1987-01-01 2023-04-01 Monthly M Index Jan 2000=100 Index Jan 2000=100 Seasonally Adjusted SA 2023-06-27 08:13:03-05 80 92 For more information regarding the index, plea...
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
995 CUUS0000SAF113 2023-07-11 2023-07-11 Consumer Price Index for All Urban Consumers: ... 1984-01-01 2022-07-01 Semiannual SA Index 1982-1984=100 Index 1982-1984=100 Not Seasonally Adjusted NSA 2023-01-12 07:37:52-06 1 27 NaN
996 CUUS0000SAF116 2023-07-11 2023-07-11 Consumer Price Index for All Urban Consumers: ... 1984-01-01 2022-07-01 Semiannual SA Index 1982-1984=100 Index 1982-1984=100 Not Seasonally Adjusted NSA 2023-01-12 07:37:58-06 1 27 NaN
997 RTFPNAJPA632NRUG 2023-07-11 2023-07-11 Total Factor Productivity at Constant National... 1954-01-01 2019-01-01 Annual A Index 2017=1 Index 2017=1 Not Seasonally Adjusted NSA 2023-02-27 14:32:04-06 26 26 Source ID: rtfpna\n\nWhen using these data in ...
998 CPALTT01CHM657N 2023-07-11 2023-07-11 Consumer Price Index: All Items: Total: Total ... 1960-01-01 2023-05-01 Monthly M Growth rate previous period Growth rate previous period Not Seasonally Adjusted NSA 2023-06-23 12:37:05-05 17 26 OECD descriptor ID: CPALTT01\nOECD unit ID: GP...
999 CHECPIALLMINMEI 2023-07-11 2023-07-11 Consumer Price Index: All Items: Total: Total ... 1960-01-01 2023-05-01 Monthly M Index 2015=100 Index 2015=100 Not Seasonally Adjusted NSA 2023-06-23 12:37:06-05 12 26 Copyright, 2016, OECD. Reprinted with permissi...

1000 rows × 16 columns

To request information about an economic indicator, such as GDPCA, the package fredeco can be used as follows:

[5]:

fred_info_series(fred_api=my_fred_key,series='GDPCA')
[5]:
{'realtime_start': '2023-07-11',
 'realtime_end': '2023-07-11',
 'seriess': [{'id': 'GDPCA',
   'realtime_start': '2023-07-11',
   'realtime_end': '2023-07-11',
   'title': 'Real Gross Domestic Product',
   'observation_start': '1929-01-01',
   'observation_end': '2022-01-01',
   'frequency': 'Annual',
   'frequency_short': 'A',
   'units': 'Billions of Chained 2012 Dollars',
   'units_short': 'Bil. of Chn. 2012 $',
   'seasonal_adjustment': 'Not Seasonally Adjusted',
   'seasonal_adjustment_short': 'NSA',
   'last_updated': '2023-03-30 07:54:04-05',
   'popularity': 52,
   'notes': 'BEA Account Code: A191RX\n\nA Guide to the National Income and Product Accounts of the United States (http://www.bea.gov/national/pdf/nipaguid.pdf) (NIPA)'}]}

These information are essential to know, to use for analysis. For example, the last information provided, the notes, indicate the source of data. The source should be provided, when using data retrieved from FRED® API.

To search for the list of economic indicators in a category, such as the category ID 125, one can proceed as follows.

[6]:
df_list=fred_list_series(fred_api=my_fred_key,category_id=125)
df_list.head(5)
[6]:
id realtime_start realtime_end title observation_start observation_end frequency frequency_short units units_short seasonal_adjustment seasonal_adjustment_short last_updated popularity group_popularity notes
0 AITGCBN 2023-07-11 2023-07-11 Advance U.S. International Trade in Goods: Bal... 2023-05-01 2023-05-01 Monthly M Millions of Dollars Mil. of $ Not Seasonally Adjusted NSA 2023-06-28 07:31:03-05 2 23 This advance estimate represents the current m...
1 AITGCBS 2023-07-11 2023-07-11 Advance U.S. International Trade in Goods: Bal... 2023-05-01 2023-05-01 Monthly M Millions of Dollars Mil. of $ Seasonally Adjusted SA 2023-06-28 07:31:01-05 23 23 This advance estimate represents the current m...
2 BOPBCA 2023-07-11 2023-07-11 Balance on Current Account (DISCONTINUED) 1960-01-01 2014-01-01 Quarterly Q Billions of Dollars Bil. of $ Seasonally Adjusted SA 2014-06-18 08:41:28-05 7 8 This series has been discontinued as a result ...
3 BOPBCAA 2023-07-11 2023-07-11 Balance on Current Account (DISCONTINUED) 1960-01-01 2013-01-01 Annual A Billions of Dollars Bil. of $ Not Seasonally Adjusted NSA 2014-06-18 08:41:28-05 2 8 This series has been discontinued as a result ...
4 BOPBCAN 2023-07-11 2023-07-11 Balance on Current Account (DISCONTINUED) 1960-01-01 2014-01-01 Quarterly Q Billions of Dollars Bil. of $ Not Seasonally Adjusted NSA 2014-06-18 08:41:28-05 1 8 This series has been discontinued as a result ...

The code below allows to retrieve a list of the dates of the releases of an indicator. The illustration below considers the indicator ID FEDFUNDS.

[7]:
fred_vintagedates(fred_api=my_fred_key, series='FEDFUNDS')
[7]:
['1996-12-03',
 '1997-01-07',
 '1997-02-04',
 '1997-03-04',
 '1997-04-08',
 '1997-05-06',
 '1997-06-03',
 '1997-07-08',
 '1997-08-05',
 '1997-09-02',
 '1997-10-07',
 '1997-11-04',
 '1997-12-02',
 '1997-12-10',
 '1998-01-06',
 '1998-02-03',
 '1998-03-03',
 '1998-04-07',
 '1998-05-05',
 '1998-06-02',
 '1998-07-07',
 '1998-08-04',
 '1998-09-08',
 '1998-10-06',
 '1998-11-03',
 '1998-12-08',
 '1999-01-05',
 '1999-02-02',
 '1999-03-02',
 '1999-04-06',
 '1999-05-04',
 '1999-06-08',
 '1999-07-06',
 '1999-08-03',
 '1999-09-07',
 '1999-10-05',
 '1999-11-02',
 '1999-12-07',
 '2000-01-04',
 '2000-02-08',
 '2000-03-07',
 '2000-04-04',
 '2000-05-02',
 '2000-06-06',
 '2000-07-05',
 '2000-08-08',
 '2000-09-05',
 '2000-10-03',
 '2000-11-07',
 '2000-12-05',
 '2001-01-02',
 '2001-02-06',
 '2001-03-06',
 '2001-04-03',
 '2001-05-08',
 '2001-06-05',
 '2001-07-03',
 '2001-08-07',
 '2001-09-04',
 '2001-10-02',
 '2001-11-06',
 '2001-12-04',
 '2002-01-08',
 '2002-02-04',
 '2002-03-04',
 '2002-04-01',
 '2002-05-06',
 '2002-06-03',
 '2002-07-01',
 '2002-08-05',
 '2002-09-03',
 '2002-10-07',
 '2002-11-04',
 '2002-12-02',
 '2003-01-06',
 '2003-02-03',
 '2003-03-03',
 '2003-04-07',
 '2003-05-05',
 '2003-06-02',
 '2003-07-07',
 '2003-08-04',
 '2003-09-02',
 '2003-10-06',
 '2003-11-03',
 '2003-12-01',
 '2004-01-05',
 '2004-02-02',
 '2004-03-01',
 '2004-04-05',
 '2004-05-03',
 '2004-06-07',
 '2004-07-06',
 '2004-08-02',
 '2004-09-07',
 '2004-10-04',
 '2004-11-01',
 '2004-12-06',
 '2005-01-03',
 '2005-02-07',
 '2005-03-07',
 '2005-04-04',
 '2005-05-02',
 '2005-06-06',
 '2005-07-05',
 '2005-08-01',
 '2005-09-06',
 '2005-10-03',
 '2005-11-07',
 '2005-12-05',
 '2006-01-03',
 '2006-02-06',
 '2006-03-06',
 '2006-04-03',
 '2006-05-01',
 '2006-06-05',
 '2006-07-03',
 '2006-08-07',
 '2006-09-05',
 '2006-10-02',
 '2006-11-06',
 '2006-12-04',
 '2007-01-03',
 '2007-02-05',
 '2007-03-05',
 '2007-04-02',
 '2007-05-07',
 '2007-06-04',
 '2007-07-02',
 '2007-08-06',
 '2007-09-04',
 '2007-10-01',
 '2007-11-05',
 '2007-12-03',
 '2008-01-07',
 '2008-02-04',
 '2008-03-03',
 '2008-04-07',
 '2008-05-05',
 '2008-06-02',
 '2008-07-07',
 '2008-08-04',
 '2008-09-02',
 '2008-10-06',
 '2008-11-03',
 '2008-12-01',
 '2009-01-05',
 '2009-02-02',
 '2009-03-02',
 '2009-04-06',
 '2009-05-04',
 '2009-06-01',
 '2009-07-06',
 '2009-08-03',
 '2009-09-08',
 '2009-10-05',
 '2009-11-02',
 '2009-12-07',
 '2010-01-04',
 '2010-02-01',
 '2010-03-01',
 '2010-04-05',
 '2010-05-03',
 '2010-06-07',
 '2010-07-06',
 '2010-08-02',
 '2010-09-07',
 '2010-10-04',
 '2010-11-01',
 '2010-12-06',
 '2011-01-03',
 '2011-01-10',
 '2011-01-11',
 '2011-02-07',
 '2011-03-07',
 '2011-04-04',
 '2011-05-02',
 '2011-06-06',
 '2011-07-05',
 '2011-08-01',
 '2011-09-06',
 '2011-10-11',
 '2011-11-07',
 '2011-12-05',
 '2012-01-09',
 '2012-02-06',
 '2012-03-05',
 '2012-04-02',
 '2012-05-07',
 '2012-06-04',
 '2012-07-02',
 '2012-08-06',
 '2012-09-04',
 '2012-10-01',
 '2012-11-05',
 '2012-12-10',
 '2013-01-07',
 '2013-02-04',
 '2013-03-04',
 '2013-04-04',
 '2013-05-06',
 '2013-06-10',
 '2013-07-08',
 '2013-08-12',
 '2013-09-03',
 '2013-10-07',
 '2013-11-04',
 '2013-12-02',
 '2014-01-06',
 '2014-02-03',
 '2014-03-04',
 '2014-04-07',
 '2014-05-05',
 '2014-06-02',
 '2014-07-10',
 '2014-08-04',
 '2014-09-02',
 '2014-10-06',
 '2014-11-03',
 '2014-12-01',
 '2015-01-05',
 '2015-02-02',
 '2015-03-02',
 '2015-04-06',
 '2015-05-04',
 '2015-06-01',
 '2015-07-01',
 '2015-08-03',
 '2015-09-14',
 '2015-10-05',
 '2015-11-02',
 '2015-12-07',
 '2016-01-04',
 '2016-02-01',
 '2016-03-07',
 '2016-04-04',
 '2016-05-02',
 '2016-06-06',
 '2016-07-05',
 '2016-08-01',
 '2016-09-06',
 '2016-10-03',
 '2016-11-03',
 '2016-12-01',
 '2017-01-03',
 '2017-02-01',
 '2017-03-01',
 '2017-04-03',
 '2017-05-01',
 '2017-06-01',
 '2017-07-03',
 '2017-08-01',
 '2017-09-01',
 '2017-10-02',
 '2017-11-01',
 '2017-12-01',
 '2018-01-02',
 '2018-02-01',
 '2018-03-01',
 '2018-04-02',
 '2018-05-01',
 '2018-06-01',
 '2018-07-02',
 '2018-08-01',
 '2018-09-04',
 '2018-10-01',
 '2018-11-01',
 '2018-12-03',
 '2019-01-02',
 '2019-02-01',
 '2019-03-01',
 '2019-04-01',
 '2019-05-01',
 '2019-06-03',
 '2019-07-01',
 '2019-08-01',
 '2019-09-03',
 '2019-10-01',
 '2019-11-01',
 '2019-12-02',
 '2020-01-02',
 '2020-02-03',
 '2020-03-02',
 '2020-04-01',
 '2020-05-01',
 '2020-06-01',
 '2020-07-01',
 '2020-07-21',
 '2020-08-03',
 '2020-08-05',
 '2020-09-01',
 '2020-10-01',
 '2020-10-13',
 '2020-11-02',
 '2020-12-01',
 '2021-01-04',
 '2021-02-01',
 '2021-03-01',
 '2021-04-01',
 '2021-05-03',
 '2021-06-01',
 '2021-07-01',
 '2021-08-02',
 '2021-09-01',
 '2021-10-01',
 '2021-11-01',
 '2021-12-01',
 '2022-01-03',
 '2022-02-01',
 '2022-03-01',
 '2022-04-01',
 '2022-05-02',
 '2022-06-01',
 '2022-07-01',
 '2022-08-01',
 '2022-09-01',
 '2022-10-03',
 '2022-11-01',
 '2022-12-01',
 '2023-01-03',
 '2023-02-01',
 '2023-03-01',
 '2023-04-03',
 '2023-05-01',
 '2023-06-01',
 '2023-07-03']

Explore data

After retrieving data, one can use a fredeco function to get some statistics and other informations about them. This is possible for one or several indicators, as illustrated below. We use the df_one and df_multi, the objects where have been stored data retrieved previously.

[18]:
explore(fred_api=my_fred_key,data=df_one)
[18]:
GDP
Units Billions of Dollars
N 76
Mean 6873.642447
Median 4188.2975
Std 7055.960951
Min 249.616
Max 25462.722
CV 1.019748
25% quantile 795.633
50% quantile 4188.2975
75% quantile 11646.6365
skewness 0.916755
kurtosis -0.34893
[19]:
explore(fred_api=my_fred_key,data=df_multi)
[19]:
GDP GDPCA
Units Billions of Dollars Billions of Chained 2012 Dollars
N 76 77
Mean 6873.642447 9018.846338
Median 4188.2975 7637.704
Std 7055.960951 5516.176475
Min 249.616 2036.204
Max 25462.722 20014.128
CV 1.019748 0.607643
25% quantile 795.633 4173.424
50% quantile 4188.2975 7637.704
75% quantile 11646.6365 13865.519
skewness 0.916755 0.449427
kurtosis -0.34893 -1.146103

To explore data retrieved, one can quickly plot them, using the package matplotlib. That’s why it has been called with import matplotlib previously.

[21]:
df_one.tail(20).plot()
[21]:
<Axes: xlabel='Dates'>
_images/examples_24_1.png
[22]:
df_multi.tail(20).plot()
[22]:
<Axes: xlabel='Dates'>
_images/examples_25_1.png