Additional fredpy Functions

fredpy.divide(object1, object2)

Divides the data from object1 by the data from object2.

Parameters:
Returns:

fredpy.series

fredpy.fred_api_request(api_key, path, parameters)

Queries the FRED API. Returns a requests.models.Response object if successful, otherwise will raise an error with a message that is hopefully helpful. Reference for API querries: https://fred.stlouisfed.org/docs/api/fred/

Parameters:
  • api_key (str) – Your 32-character FRED API Key.

  • path (str) – Path for FRED API.

  • parameters (dict) – Dictionary containing appropriate parameters and values for the API query

Returns:

requests.models.Response

fredpy.get_vintage_dates(series_id)

Returns vintage dates for series available from ALFRED.

Parameters:

series_id (str) – ID of FRED series.

Returns:

list

fredpy.minus(object1, object2)

Subtracts the data from object2 from the data from object1.

Parameters:
Returns:

fredpy.series

fredpy.plus(object1, object2)

Adds the data from object1 to the data from object2.

Parameters:
Returns:

fredpy.series

fredpy.recessions(start=None,end=None,ax=None,color='0.5',alpha=0.5):

Creates recession bars for time series plots.

Parameters:
  • start (str or Timestamp) – Starting date. Default: None

  • end (str or Timestamp) – Ending date. Default: None

  • ax (matplotlib.axes._subplots.AxesSubplot) – Matplotlib axis object to plot recession bars. Default: None

  • color (str) – Color of the bars. Default: ‘0.5’.

  • alpha (float) – Transparency of the recession bars. Must be between 0 and 1. Default: 0.5.

Returns:

fredpy.times(object1, object2)

Multiplies the data from object1 with the data from object2.

Parameters:
Returns:

fredpy.series

fredpy.toFredSeries(data, dates, frequency='', frequency_short='', last_updated='', notes='', release='', seasonal_adjustment='', seasonal_adjustment_short='', series_id='', source='', t=0, title='', units='', units_short='')

Create a fredpy.series from time series data not obtained from FRED.

Parameters:
  • data (numpy.ndarray, Pandas.Series, or list) – Data values.

  • dates (list or numpy.ndarry) – Array or list of dates. Elements formatted as either string (YYYY-MM-DD or MM-DD-YYYY) or pandas.tslib.Timestamp.

  • frequency (str) – Observation frequency. Options: ‘’, ‘Daily’, ‘Weekly’, ‘Monthly’, ‘Quarterly’, or ‘Annual’. Default: empty string.

  • frequency_short (str) – Observation frequency abbreviated. Options: ‘’, ‘D’, ‘W’, ‘M’, ‘Q’, or ‘A’. Default: empty string.

  • last_updated (str) – Date data was last updated. Default: empty string.

  • notes (str) – Default: empty string.

  • release (str) – Notes about data. Default: empty string.

  • seasonal_adjustment (str) – Default: empty string.

  • seasonal_adjustment_short (str) – Default: empty string.

  • series_id (str) – FRED series ID. Default: empty string.

  • source (str) – Source of the data. Default: empty string.

  • t (int) – Number of observations per year. Default: 0

  • title (str) – Title of the data. Default: empty string.

  • units (str) – Units of the data. Default: empty string.

  • units_short (str) – Units of the data. Abbreviated. Default: empty string.

Returns:

fredpy.series

fredpy.window_equalize(series_list)

Adjusts the date windows for a collection of fredpy.series objects to the smallest common window.

Parameters:

series_list (list) – A list of fredpy.series objects

Returns:

list of fredpy.series