Skip to main content

Federal Package

This is a simple module built on top of Pandas-Datareader to make it easer to pull in Federal Reserve Data from the Federal Reserve in St. Louis (FRED).

Installation

pip install Federal

Basic Usage:

# Import the GDP and DateFormatter Modules
from Federal.Econ import GDP
from Federal.Formatter import DateFormatter

#Insatiate the GDP and DateFormatter Objects
g = GDP()
d = DateFormatter()

#Set your Start & End Dates
d.start_date(1900,1,1)
d.end_date(2018,1,1)

# Make the Call
df = g.metro_gdp(name='Houston')
df.head()

Setting Start & End Dates

Once imported, you declare the start date and end date via the DateFormatter.start_date() and DateFormatter.end_date() functions. These functions define the range of dates for the data that you are for. Once declared these values will be applied to each query unless explicitly changed.

There are several different DateTime format variants that the DateFormatter.start_date() and DateFormatter.end_date() functions accept:

  1. DateTime format: (Year, Month, Day): Integer
# Import the DateFormatter Modules
from Federal.Formatter import DateFormatter

#Insatiate the DateFormatter Object
d = DateFormatter()

d.start_date(1900,1,1)
d.end_date(2018,1,1)
  1. DateTime format: (Day/Month/Year): String
# Import the DateFormatter Modules
from Federal.Formatter import DateFormatter

#Insatiate the DateFormatter Object
d = DateFormatter()

d.start_date('1/1/1900')
d.end_date('1/1/2018')
  1. DateTime format: (Day-Month-Year): String
# Import the DateFormatter Modules
from Federal.Formatter import DateFormatter

#Insatiate the DateFormatter Object
d = DateFormatter()

d.start_date('1-1-1900')
d.end_date('1-1-2018')
  1. DateTime format: (Day.Month.Year): String
# Import the DateFormatter Modules
from Federal.Formatter import DateFormatter

#Insatiate the DateFormatter Object
d = DateFormatter()

d.start_date('1.1.1900')
d.end_date('1.1.2018')
  1. DateTime format: (Month/Day/Year): String
# Import the DateFormatter Modules
from Federal.Formatter import DateFormatter

#Insatiate the DateFormatter Object
d = DateFormatter()

d.start_date('14/1/1900')
d.end_date('16/1/2018')

National Gross Domestic Product (GDP)

After instantiating a FRED object, and defining the start and end dates using the GDP.start_date() and GDP.end_date() functions you can use the function GDP.national_gdp() depending on its parameters to return either nominal GDP or real GDP.

# Import the GDP and DateFormatter Modules
from Federal.Econ import GDP
from Federal.Formatter import DateFormatter

#Insatiate the GDP and DateFormatter Objects
g = GDP()
d = DateFormatter()

#Set Dates
d.start_date('1/1/1900')
d.end_date('1/1/2018')

# Real GDP
df = g.national_gdp()
df.head()

# Nominal GDP
df = g.national_gdp(nominal=True)
df.head()

State Gross Domestic Product (GSP)

Similar to the GDP.national_gdp() after making the necessary calls you can pull in information around State-Level GDP using the GDP.state_gdp() function. It requires one argument, which is the two-character string representing the state of interest. In the case below we pull the state GDP for Indiana.

# Import the GDP and DateFormatter Modules
from Federal.Econ import GDP
from Federal.Formatter import DateFormatter

#Insatiate the GDP and DateFormatter Objects
g = GDP()
d = DateFormatter()

#Set the Dates
d.start_date('1/1/1900')
d.end_date('1/1/2018')

# State GDP
df = g.state_gdp('IN')
df.head()

Metropolitan Gross Domestic Product (GMP)

The final variation of GDP that the FRED module pulls in is Metropolitan-Level GDP. The Federal Reserve uses Core-Based Statistical Area (CBSA) Codes to define each metro within their API. Here using the GDP.metro_gdp() function you can either pass the CBSA code or a name of a metro area as arguments within the function. Beyond this, similar to national GDP, by passing GDP.metro_gdp(name='<Any Metro Name>',nominal=True) with nominal equal to True, the function will return the nominal metro GDP.

# Import the GDP and DateFormatter Modules
from Federal.Econ import GDP
from Federal.Formatter import DateFormatter

#Insatiate the GDP and DateFormatter Objects
g = GDP()
d = DateFormatter()

#Set the Dates
d.start_date('1/1/1900')
d.end_date('1/1/2018')

# Metropolitan GDP - Passing the City Name as an argument
df = g.metro_gdp(name='Houston')
df.head()

# Metropolitan GDP - Passing the CBSA code as an argument
df = g.metro_gdp(cbsa=26420)
df.head()

# Metropolitan GDP - nominal
df = g.metro_gdp(cbsa=26420, nominal=True)
df.head()

# Metropolitan GDP - nominal
df = g.metro_gdp(name='Houston', nominal=True)
df.head()

National Unemployment

Unemployment is defined by the Unemployment.national_unemp() function. This function takes an argument sa which returns either seasonally-adjusted non seasonally-adjusted unemployment.

# Import the GDP and DateFormatter Modules
from Federal.Econ import Unemployment
from Federal.Formatter import DateFormatter

#Insatiate the GDP and DateFormatter Objects
u = Unemployment()
d = DateFormatter()

#Set the Dates
d.start_date('1/1/1900')
d.end_date('1/1/2018')

# Seasonally-Adjusted National Unemployment
df = u.national_unemp(sa=True)
df.head()

# Non Seasonally-Adjusted National Unemployment
df = u.national_unemp(sa=False)
df.head()

Release files for Federal 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Federal 1.0.1
File Size Uploaded
Federal-1.0.1.tar.gz 13.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Federal 1.0.1
File Interpreter ABI Platform
Federal-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 31.1 kB

Release files / Federal-1.0.1.tar.gz

Download URL Federal-1.0.1.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
10fbd63e0b9eec741fbb5e74fc623c7660fce23dc0a355ce2633bbdc376f92d0
BLAKE2b-256 checksum
How to use checksums
0ee25d1ca569625194e5fd55b880fb38879f3829231786cc9db151e5ccd16ef3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

Release files / Federal-1.0.1-py3-none-any.whl

Download URL Federal-1.0.1-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08777b069cdbb83ac918b79902baa610ebbedb1c7efdf4f4852328f8d5ed1e8e
BLAKE2b-256 checksum
How to use checksums
659064c357d6faa1ae5c5463e233a50e451518676a2f8f3baaf1c9ba3891c827
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.0.2

2 release files

0.0.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page