get_regional_data#
- async AsyncMapsAPI.get_regional_data(series_group, region_type, date, season, units, geodataframe_method='geopandas', start_date=None, transformation=None, frequency=None, aggregation_method=None)#
Get GeoFRED regional data
Retrieve regional data for a specified series group and date from the FRED Maps API.
- Parameters:
series_group (str) – The series group for which you want to request regional data.
region_type (str) – The type of region for which you want to request data. Options are ‘bea’, ‘msa’, ‘frb’, ‘necta’, ‘state’, ‘country’, ‘county’, ‘censusregion’, or ‘censusdivision’.
date (str | datetime) – The date for which you want to request regional data. String format: YYYY-MM-DD.
season (str) – The seasonality of the data. Options include ‘seasonally_adjusted’ or ‘not_seasonally_adjusted’.
units (str) – The units of the data. Options are ‘lin’, ‘chg’, ‘ch1’, ‘pch’, ‘pc1’, ‘pca’, ‘cch’, ‘cca’ and ‘log’.
geodataframe_method (str, optional) – The method to use for creating the GeoDataFrame. Options are ‘geopandas’, ‘dask’ or ‘polars’. Default is ‘geopandas’.
start_date (str, optional) – The start date for the range of data you want to request. Format: YYYY-MM-DD.
transformation (str, optional) – The data transformation to apply. Options are ‘lin’, ‘chg’, ‘ch1’, ‘pch’, ‘pc1’, ‘pca’, ‘cch’, ‘cca’, and ‘log’.
frequency (str, optional) – The frequency of the data. Options are ‘d’, ‘w’, ‘bw’, ‘m’, ‘q’, ‘sa’, ‘a’, ‘wef’, ‘weth’, ‘wew’, ‘wetu’, ‘wem’, ‘wesu’, ‘wesa’, ‘bwew’and ‘bwem’.
aggregation_method (str, optional) – The aggregation method to use. Options are ‘avg’, ‘sum’, and ‘eop’.
- Returns:
If geodataframe_method is ‘geopandas’. Dask GeoPandas GeoDataframe: If geodataframe_method is ‘dask’. Polars GeoDataframe: If geodataframe_method is ‘polars’.
- Return type:
GeoPandas GeoDataframe
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> import asyncio >>> async def main(): >>> fred = fd.FredMapsAPI('your_api_key').Async.Maps >>> regional_data = fred.get_regional_data(series_group='882', date='2013-01-01', region_type='state', units='Dollars', frequency='a', season='NSA') >>> print(regional_data.head()) >>> asyncio.run(main()) name geometry hc-group ... value series_id Massachusetts MULTIPOLYGON (((9727 7650, 10595 7650, 10595 7... admin1 ... 56119 MAPCPI Washington MULTIPOLYGON (((-77 9797, -56 9768, -91 9757, ... admin1 ... 47448 WAPCPI California POLYGON ((-833 8186, -50 7955, -253 7203, 32 6... admin1 ... 48074 CAPCPI Oregon POLYGON ((-50 7955, -833 8186, -851 8223, -847... admin1 ... 39462 ORPCPI Wisconsin MULTIPOLYGON (((6206 8297, 6197 8237, 6159 815... admin1 ... 42685 WIPCPI [5 rows x 21 columns]
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/geofred/regional_data.html