fied.frs package¶
Submodules¶
fied.frs.frs_extraction module¶
- class FRS[source]¶
Bases:
object
Class for extracting relevant facility-level data from EPA’s Facility Registration Service (FRS) data.
Documentation of FRS data fields: https://www.epa.gov/sites/default/files/2015-09/documents/frs_data_dictionary.pdf
- call_all_fips()[source]¶
Uses Census API to call all state and county fips codes. Excludes U.S. territories and outerlying areas. Combines with file on stat abbrevitions and zip codes.
- Returns:
all_fips
- Return type:
json
- format_program_csv(data, programs)[source]¶
Builds dataframe from FRS_PROGRAM dataset.
- Parameters:
data (pandas.DataFrame) – Initial imported DataFrame.
programs (list) – List of program system acronyms to extract.
- Returns:
data – Formatted FRS data
- Return type:
pandas.DataFrame
- format_naics_csv(data)[source]¶
Builds dataframe from FRS_FACILITY dataset.
- Parameters:
data (pandas.DataFrame) – Initial imported DataFrame.
- Returns:
data – Formatted FRS data
- Return type:
pandas.DataFrame
- read_frs_csv(name, columns, programs=['EIS', 'E-GGRT'])[source]¶
Builds dataframe based on FRS datasets.
- Parameters:
name (str) – String for name of FRS csv file. All csv files extracted from national_combined.zip are named according to “NATIONAL_{name}_FILE.CSV”.
columns (list) – List of columns to extract from csv.
programs (list; ['EIS', 'E-GGRT']) – List of program system acronyms to extract from NATIONAL_PROGRAM_FILE.CSV.
- Returns:
data – Formatted FRS data, based on FACILITY, ORGANIZATION, NAICS, and PROGRAM datasets.
- Return type:
pandas.DataFrame
- build_frs_json(frs_data_df, save_path=None, ret=False)[source]¶
- Parameters:
frs_data_df (pandas.DataFrame) – Dataframe from formatted FRS csv datasets.
ret (bool; default == False) – Returns FRS data in json format.
save_path (str; default == None) – Directory to save FRS data in json file. Must specify to save.
- Returns:
frs_json – Dictionary of facility data extracted from FRS in JSON format.
- Return type:
json, optional.
- import_format_frs(combined=True)[source]¶
Import and format downloaded frs files
- Parameters:
file_dir (str) – Directory of FRS files.
combined (bool; default is True) – Indicate whether the data set is constructed using the EPA FRS single file or combined files.
- Returns:
final_data – DataFrame indexed by REGISTRY_ID, containing relevant site and facility data from EPA FRS.
- Return type:
pandas.DataFrame