synthpops.contact_networks_industries module

This module uses workplace data by industry from North American Industry Classification System (NAICS) codes to model workplaces as specific industries and the contact patterns for workers within each workplace.

synthpops.contact_networks_industries.get_establishments_by_industries_df(datadir, locations, state_location, country_location, level)

Filter a pandas DataFrame on establishment sizes by industry for the locations of interest at the county level.

Parameters
  • datadir (string) – The file path to the data directory.

  • locations (list of string) – A list with the names of the locations at the county level.

  • state_location (string) – The name of the state the location is in.

  • country_location (string) – The name of the country the location is in.

  • level (string) – The scale of region at which data is available.

Returns

A pandas DataFrame with necessary columns to calculate establishment sizes by industry for the specified locations of interest.

synthpops.contact_networks_industries.get_industry_type_df(datadir, country_location)

Get the 2017 NAICS US Codes and Titles.

Parameters
  • datadir (string) – The file path to the data directory.

  • country_location (string) – The name of the country.

Returns

A pandas DataFrame with 2017 NAICS US Code and Title.

synthpops.contact_networks_industries.get_simplified_industry_type_df(datadir, country_location)

Get the simplified 2017 NAICS US Codes.

Parameters
  • datadir (string) – The file path to the data directory.

  • country_location (string) – The name of the country.

Returns

A pandas DataFrame with 2 digit 2017 NAICS US Codes mapping to main industry types.

synthpops.contact_networks_industries.get_industry_code(industry_type_df, industry_title)

Get the 2017 NAICS Code based on industry title.

Parameters
  • industry_type_df (dataframe) – The pandas DataFrame.

  • industry_title (string) – The 2017 NAICS US Title.

Returns

The 2017 NAICS US Code as an integer.

synthpops.contact_networks_industries.get_main_industry_code(industry_type_df, industry_title)

Get the 2-digit 2017 NAICS US Code based on industry title.

Parameters
  • industry_type_df (DataFrame) – The pandas DataFrame.

  • industry_title (string) – The 2017 NAICS US Title.

Returns

The 2-digit 2017 NAICS US Code as an integer.

synthpops.contact_networks_industries.get_industry_title(industry_type_df, industry_code)

Get the 2017 NAICS US Title based on full industry code.

Parameters
  • industry_type_df (DataFrame) – The pandas DataFrame.

  • industry_code (int) – The 2017 NAICS US Code.

Returns

The 2017 NAICS US Title.

synthpops.contact_networks_industries.get_main_industry_title(industry_type_df, industry_code)

Get the main 2017 NAICS US Title based on 2-digit industry code.

Parameters
  • industry_type_df (DataFrame) – The pandas DataFrame.

  • industry_code (int) – The 2-digit 2017 NAICS US Code.

Returns

The 2017 NAICS US Title.

synthpops.contact_networks_industries.get_simplified_industry_title(simplified_industry_type_df, industry_code)

Get the simplified 2017 NAICS US Title from the 2-digit 2017 NAICS Code.

Parameters
  • simplified_industry_type_df (DataFrame) – The pandas DataFrame

  • industry_code (int) – The 2-digit 2017 NAICS US Code.

Returns

The 2017 NAICS US Title for the 2-digit code.

synthpops.contact_networks_industries.get_simplified_industry_code(simplified_industry_type_df, industry_title)

Get the simplified 2017 NAICS US Code from the full title.

Parameters
  • simplified_industry_type_df (DataFrame) – The pandas DataFrame.

  • industry_title (string) – The full 2017 NAICS US Title.

Returns

The 2-digit 2017 NAICS US Code.

synthpops.contact_networks_industries.get_establishment_size_brackets_df(datadir, locations, state_location='Washington', country_location='usa', level='county')

Get size brackets DataFrame from Bureau of Labor Statistics (BLS) 2017 Data.

Parameters
  • datadir (string) – The file path to the data directory.

  • locations (list) – A list with the names of the locations at the county level.

  • state_location (string) – The name of the state the location is in.

  • country_location (string) – The name of the country the location is in.

  • level (string) – The scale of region at which data is available.

Returns

A Dataframe of size brackets for establishments in the United States.

synthpops.contact_networks_industries.generate_synthetic_population_with_workplace_industries(n, datadir, location='seattle_metro', state_location='Washington', country_location='usa', sheet_name='United States of America', level='county', verbose=False, plot=False)

Modify the workplace network as generated by generate_synthetic_population() to include contact patterns according to each industry.

Parameters
  • n (int) – The number of people in the population.

  • datadir (string) – The file path to the data directory.

  • location (string) – The name of the location.

  • state_location (string) – The name of the state the location is in.

  • country_location (string) – The name of the country the location is in.

  • sheet_name (string) – The name of the sheet in the Excel file with contact patterns.

  • level (string) – The scale of region at which data is available.

  • verbose (bool) – If True, print statements as contacts are being generated.

  • plot (bool) – If True, plot and show a comparison of the generated workplace sizes vs. the expected sizes based on NAICS data.

Returns

None