API documentation

wellbeing.generate_chart.budget_deficit(start_year: Optional[Union[int, str, Period]] = None, end_year: Optional[Union[int, str, Period]] = None, y_range=(- 8, 20), from_cache: bool = False, save_to_cache: bool = True) Column

U.S. Budget Deficits: Federal Government Debt Service and Debt

Creates a graph of federal net borrow to income and federal debt service ratio.

Parameters:
  • start_year (Union[int,str,pd.Period], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[int,str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • y_range (tuple, optional) – Y-axis range. Defaults to (-8, 20).

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

wellbeing.generate_chart.business_cycle_table(start_quarter: Optional[Union[int, str, Period]] = None, end_quarter: Optional[Union[int, str, Period]] = None, from_cache: bool = False, save_to_cache: bool = True) str

Trends in U.S. Business Cycles: Rates of Change and Duration (table)

Creates a table of contractions/expansions with their average change in GDP.

Parameters:
  • start_quarter (Union[int,str,pd.Period], optional) – Start quarter. Defaults to None, which uses the value in chart_config.yml.

  • end_quarter (Union[int,str,pd.Period], optional) – End quarter. Defaults to None, which uses the value in chart_config.yml.

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

str

wellbeing.generate_chart.business_cycles(start_quarter: Optional[Union[int, str, Period]] = None, end_quarter: Optional[Union[int, str, Period]] = None, from_cache: bool = False, save_to_cache: bool = True) Column

Trends in U.S. Business Cycles: Rates of Change and Duration (chart)

Creates a graph of real GDP highlighting the most recent contraction and expansion.

Parameters:
  • start_quarter (Union[int,str,pd.Period], optional) – Start quarter. Defaults to None, which uses the value in chart_config.yml.

  • end_quarter (Union[int,str,pd.Period], optional) – End quarter. Defaults to None, which uses the value in chart_config.yml.

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

wellbeing.generate_chart.economic_growth_tables(start_year: Union[int, str, Period], mid_year: Union[int, str, Period], end_year: Union[int, str, Period], from_cache: bool = False, save_to_cache: bool = True) str

Trends in Economic Growth

Creates a table of economic growth from start_year to mid_year and mid_year to end_year.

Parameters:
  • start_year (Union[int,str,pd.Period]) – Start year

  • mid_year (Union[int,str,pd.Period]) – Mid year

  • end_year (Union[int,str,pd.Period]) – End year

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). This function uses BLS queries and the cache only works if start_year and end_year remain the same. Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

HTML representation of Table

Return type:

str

wellbeing.generate_chart.employment(start_year: Optional[Union[int, str, Period]] = None, end_year: Optional[Union[int, str, Period]] = None, y_range: Tuple = (20, 100), y_range2: Tuple = (2, 10), from_cache: bool = False, save_to_cache: bool = True, **kwargs) Column

Employment Trend

Graph FTE employment rate, Prime age employment rate, and unemployment rate

Parameters:
  • start_year (Union[int,str,pd.Period], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[int,str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • y_range (Tuple, optional) – Primary (left) y-axis range (percent). Defaults to (20, 100).

  • y_range2 (Tuple, optional) – Secondary (right) y-axis range (percent). Defaults to (2, 10).

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

wellbeing.generate_chart.federal_budget(start_year: Optional[Union[int, str, Period]] = None, end_year: Optional[Union[int, str, Period]] = None, from_cache: bool = False, save_to_cache: bool = True) Column

U.S. Budget and the Economy Over Time: Federal Surpluses and Deficits as a Percentage of GDP

Creates a graph of budget surpluses and deficits.

Parameters:
  • start_year (Union[int,str,pd.Period], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[int,str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

wellbeing.generate_chart.financing_trade(start_year: Optional[Union[int, str, Period]] = None, end_year: Optional[Union[int, str, Period]] = None, y_range=(- 16, 16), from_cache: bool = False, save_to_cache: bool = True) Column

Financing International Trade: Foreign Debt Service and Debt

Creates a graph of ratios of foreign debt service (to exports and to income) and the ratio of international debt to assets.

Parameters:
  • start_year (Union[int,str,pd.Period], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[int,str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • y_range (tuple, optional) – Y-axis range. Defaults to (-16, 16).

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

wellbeing.generate_chart.foreign_subsidiary_employment(years=[1997, 2000, 2007, 2019, 2020], from_cache: bool = False, save_to_cache: bool = True) str

U.S. Multinational Companies’ Employment in U.S. and Foreign Subsidiaries (table 2)

Creates a table of share of foreign subsidary employment by level of country income

Parameters:
  • years (list, optional) – Years. Defaults to [1997,2000,2007,2019,2020].

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

HTML table

Return type:

str

wellbeing.generate_chart.foreign_subsidiary_sales_table(year: Optional[Union[int, str, Period]] = None, from_cache: bool = False, save_to_cache: bool = True) str

U.S. Multinational Companies’ Employment in U.S. and Foreign Subsidiaries (table 1)

Creates a table of foreign subsidiary sales

Parameters:
  • year (Union[int,str,pd.Period], optional) – Year. Defaults to None, which uses the value in chart_config.yml.

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

HTML table

Return type:

str

wellbeing.generate_chart.gdp(start_year: Optional[Union[int, str, Period]] = None, end_year: Optional[Union[int, str, Period]] = None, index_year: Optional[Union[int, str, Period]] = None, mid1=1973, mid2=2007, from_cache: bool = False, save_to_cache: bool = True) Tuple[Column, str]

GDP and GDP Per Capita

Creates a graph of GDP and GDP per capita relative to an index year and table showing growth from start_year to mid1, mid1 to mid2, and mid2 to end_year.

Parameters:
  • start_year (Union[int,str,pd.Period], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[int,str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • index_year (Union[int,str,pd.Period], optional) – Index year used to make levels relative. Defaults to None, which uses the value in chart_config.yml.

  • mid1 (int, optional) – First mid point for table. Defaults to 1973.

  • mid2 (int, optional) – Second mid point for table. Defaults to 2007.

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

(Column layout of the graph and metadata,

html rendering of growth table)

Return type:

Tuple[bokeh.layouts.Column, str]

wellbeing.generate_chart.gdppc_comparison(start_year: Optional[Union[int, str, Period]] = None, end_year: Optional[Union[int, str, Period]] = None, countries: Optional[list] = None, y_range=(0, 80000), from_cache: bool = False, save_to_cache: bool = True) Column

Per Capita Comparison with G-7 Developed Economies and Selected Other Countries

Compares GDP per capital between start_year and end_year across countries.

Parameters:
  • start_year (Union[int,str,pd.Period], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[int,str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • countries (list, optional) – None. Defaults to None, which uses the value in chart_config.yml.

  • y_range (tuple, optional) – Y-axis range for graphing. Defaults to (0, 80000).

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

wellbeing.generate_chart.get_narrative(section: str)

Get the narrative for a section

Parameters:

section (str) – the section in the chart_config.yml

wellbeing.generate_chart.income_growth_and_distribution(start_year: Optional[Union[int, str, Period]] = None, end_year: Optional[Union[int, str, Period]] = None, table_start: Optional[Union[int, str, Period]] = None, from_cache: bool = False, save_to_cache: bool = True, **kwargs) Tuple[Column, str]

Income Growth and its Distribution

Graphs real GDP per capita and real median equivalized personal income between start_year and end_year. Creates a table of the overall change for these series from start_start to end_year.

Parameters:
  • start_year (Union[int,str,pd.Period], optional) – Start year for graph. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[int,str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • table_start (Union[int,str,pd.Period], optional) – Start year for table. Defaults to None, which uses the value in chart_config.yml.

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

(Column layout of the graph and metadata, html of table)

Return type:

Tuple[bokeh.layouts.Column, str]

wellbeing.generate_chart.income_shares(start_year: Optional[Union[int, str, Period]] = None, end_year: Optional[Union[int, str, Period]] = None, y_range=(30, 70), from_cache: bool = False, save_to_cache: bool = True, **kwargs) Column

Distribution of Income Between Labor and Capital

Graphs the labor and capital shares of income.

Parameters:
  • start_year (Union[int,str,pd.Period], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[int,str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • y_range (tuple, optional) – Y-axis range. Defaults to (30, 70).

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

wellbeing.generate_chart.industry_growth(start_quarter: Optional[Union[str, Period]] = None, end_quarter: Optional[Union[str, Period]] = None, x_range: Tuple[float, float] = (- 1, 1.45), x_ticker_range: Tuple[float, float] = (- 0.4, 1.2), from_cache: bool = False, save_to_cache: bool = True) Column

Industry Comparison of Economic Growth

Growth rate of industries between start_year and end_year. Adjust x_range to ensure industry labels are visible and adjusted horizontally.

Parameters:
  • start_quarter (Union[str,pd.Period], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_quarter (Union[str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • x_range (Tuple[float,float], optional) – X-axis rage. Defaults to (-1,1.45).

  • x_ticker_range (Tuple[float,float], optional) – Range over which to mark x-ticks. Defaults to (-0.4, 1.2).

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

Inflation Trends: Percent Changes in Consumer Prices

Graphs percent change in PCE.

Parameters:
  • start_year (Union[int,str,pd.Period], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[int,str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

wellbeing.generate_chart.mne_employment(start_year: Optional[Union[int, Series]] = None, end_year: Optional[Union[int, Series]] = None, y_range=(0, 30000), from_cache: bool = False, save_to_cache: bool = True) Column

U.S. Multinational Companies’ Employment in U.S. and Foreign Subsidiaries (chart)

Creates a chart of domestic and foreign employment of US Multinational companies.

Parameters:
  • start_year (Union[int,pd.Series], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[int,pd.Series], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • y_range (tuple, optional) – Y-axis range. Defaults to (0, 30000).

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

wellbeing.generate_chart.net_worth(start_year: Optional[Union[int, str, Period]] = None, end_year: Optional[Union[int, str, Period]] = None, from_cache: bool = False, save_to_cache: bool = True, **kwargs) Column

Trends in Household Wealth as Measured by Net Worth

Graph the ratio of household net worth to DPI alongside household net worth.

Parameters:
  • start_year (Union[int,str,pd.Period], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[int,str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

wellbeing.generate_chart.saving_investment(start_year: Optional[Union[int, str, Period]] = None, end_year: Optional[Union[int, str, Period]] = None, y_range=(- 10, 20), from_cache: bool = False, save_to_cache: bool = True) Column

Saving & Investment for the Future: Net Saving and Net Investment as Percentages of GDP

Creates a graph of net savings rate and net investment rate

Parameters:
  • start_year (Union[int,str,pd.Period], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[int,str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • y_range (tuple, optional) – Y-axis range. Defaults to (-10, 20).

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

wellbeing.generate_chart.state_income(year: Optional[Union[str, Period]] = None, y_range=(0, 80000), from_cache: bool = False, save_to_cache: bool = True) Column

State Comparison of Income per capita

Comparison of income per capita in year across states.

Parameters:
  • year (Union[str,pd.Period], optional) – Year. Defaults to None, which uses the value in chart_config.yml.

  • y_range (tuple, optional) – Y-axis range. Defaults to (0, 80_000).

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

wellbeing.generate_chart.state_income_growth(start_year: Optional[Union[str, Period]] = None, end_year: Optional[Union[str, Period]] = None, from_cache: bool = False, save_to_cache: bool = True) Column

State Comparison of Personal Income Growth

Comparison of states’ income growth from start_year to end_year.

Parameters:
  • start_year (Union[str,pd.Period], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

wellbeing.generate_chart.sustainable_growth(start_year: Optional[Union[int, str, Period]] = None, end_year: Optional[Union[int, str, Period]] = None, from_cache: bool = False, save_to_cache: bool = True) Column

Sustainable Economic Growth: Real GDP vs Real Net Domestic Product

Real GDP vs Real Net Domestic Product from start_year to end_year.

Parameters:
  • start_year (Union[int,str,pd.Period], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[int,str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column

wellbeing.generate_chart.trade_balance(start_year: Optional[Union[int, str, Period]] = None, end_year: Optional[Union[int, str, Period]] = None, y_range=(0, 35), y_range2=(- 8, 6), from_cache: bool = False, save_to_cache: bool = True) Column

Trade and the U.S. Economy Over Time: Total Trade and Trade Balances as Percentages of GDP

Creates a graph of Total trades and trade balances (total, goods, services) as a percentage of GDP

Parameters:
  • start_year (Union[int,str,pd.Period], optional) – Start year. Defaults to None, which uses the value in chart_config.yml.

  • end_year (Union[int,str,pd.Period], optional) – End year. Defaults to None, which uses the value in chart_config.yml.

  • y_range (tuple, optional) – Primary y-axis range. Defaults to (0,35).

  • y_range2 (tuple, optional) – Secondary y-axis range. Defaults to (-8, 6).

  • from_cache (bool, optional) – Whether to retrieve from cache or not (and then pull data from APIs). Defaults to False.

  • save_to_cache (bool, optional) – If pulling from APIs, should we save data to the cache. Defaults to True.

Returns:

Column layout of the graph and metadata

Return type:

bokeh.layouts.Column