def load_proprietorship(soi_tree=naics.generate_tree(), from_out=False, get_all=False, get_nonfarm=False, get_farm=False, output_data=False, out_path=None): """ Loading the proprietorship tax soi data into a NAICS Tree. :param soi_tree: The NAICS tree to put all of the data in. :param from_out: If the corporate soi data is already in an output file, then it can be read in directly from the output. :param output_data: Print the corporate dataframes to csv files in the output folder. :param out_path: The output_path, both for reading in output data and for printing to the output file """ # Initializing the output path: if out_path == None: out_path = _OUT_DIR # Load the soi nonfarm data into the NAICS tree: if get_nonfarm: soi_tree = prop.load_soi_nonfarm_prop(data_tree=soi_tree, from_out=from_out) # Load the farm data into to the NAICS tree: if get_farm: soi_tree = prop.load_soi_farm_prop(data_tree=soi_tree, from_out=from_out) # Output the data to csv files in the output folder: if output_data: naics.print_tree_dfs(tree=soi_tree, out_path=out_path, data_types=[_NFARM_DF_NM, _FARM_DF_NM]) return soi_tree
def load_partner(soi_tree, from_out=False, output_data=False, out_path=None): """ Loading the partnership tax soi data into a NAICS Tree. :param soi_tree: The NAICS tree to put all of the data in. :param from_out: If the corporate soi data is already in an output file, then it can be read in directly from the output. :param output_data: Print the corporate dataframes to csv files in the output folder. :param out_path: The output_path, both for reading in output data and for printing to the output file """ # Initializing the output path: if out_path == None: out_path = _OUT_DIR # Load the soi income data into the NAICS tree: soi_tree = prt.load_income(data_tree=soi_tree, from_out=from_out) # Load the soi asset data into the NAICS tree: soi_tree = prt.load_asset(data_tree=soi_tree, from_out=from_out) # Load the soi partnership types data into the NAICS tree: soi_tree = prt.load_type(data_tree=soi_tree, from_out=from_out) # Output the data to csv files in the output folder: if output_data: naics.print_tree_dfs(tree=soi_tree, out_path=out_path, data_types=[_INC_DF_NM, _AST_DF_NM, _TYP_DF_NM]) return soi_tree
def load_proprietorship(soi_tree, from_out=False, get_all=False, get_nonfarm=False, get_farm=False, output_data=False, out_path=None): """ Loading the proprietorship tax soi data into a NAICS Tree. :param soi_tree: The NAICS tree to put all of the data in. :param from_out: If the corporate soi data is already in an output file, then it can be read in directly from the output. :param output_data: Print the corporate dataframes to csv files in the output folder. :param out_path: The output_path, both for reading in output data and for printing to the output file """ # Initializing the output path: if out_path == None: out_path = _OUT_DIR # Load the soi nonfarm data into the NAICS tree: if get_nonfarm: soi_tree = prop.load_soi_nonfarm_prop( data_tree=soi_tree, from_out=from_out ) # Load the farm data into to the NAICS tree: if get_farm: soi_tree = prop.load_soi_farm_prop( data_tree=soi_tree, from_out=from_out ) # Output the data to csv files in the output folder: if output_data: naics.print_tree_dfs(tree=soi_tree, out_path=out_path, data_types=[_NFARM_DF_NM, _FARM_DF_NM]) return soi_tree
def load_partner(soi_tree=naics.generate_tree(), from_out=False, output_data=False, out_path=None): """ Loading the partnership tax soi data into a NAICS Tree. :param soi_tree: The NAICS tree to put all of the data in. :param from_out: If the corporate soi data is already in an output file, then it can be read in directly from the output. :param output_data: Print the corporate dataframes to csv files in the output folder. :param out_path: The output_path, both for reading in output data and for printing to the output file """ # Initializing the output path: if out_path == None: out_path = _OUT_DIR # Load the soi income data into the NAICS tree: soi_tree = prt.load_income(data_tree=soi_tree, from_out=from_out) # Load the soi asset data into the NAICS tree: soi_tree = prt.load_asset(data_tree=soi_tree, from_out=from_out) # Load the soi partnership types data into the NAICS tree: soi_tree = prt.load_type(data_tree=soi_tree, from_out=from_out) # Output the data to csv files in the output folder: if output_data: naics.print_tree_dfs(tree=soi_tree, out_path=out_path, data_types=[_INC_DF_NM, _AST_DF_NM, _TYP_DF_NM]) return soi_tree
def load_proprietorship(soi_tree=naics.generate_tree(), from_out=False, get_all=False, get_nonfarm=False, get_farm=False, output_data=False, out_path=_OUT_DIR): # Get the nonfar if get_nonfarm: soi_tree = prop.load_soi_nonfarm_prop() if output_data: naics.print_tree_dfs(tree=soi_tree, out_path=out_path, data_types=[]) if get_farm: soi_tree = prop.load_soi_farm_prop(data_tree=soi_tree,)
def main(): # naics_tree = naics.load_naics(naics_codes_file) # read_wages.load_nipa_wages_ind(data_folder, naics_tree) # parameters = [read_wages.WAGES] # naics.pop_back(naics_tree, parameters) naics.pop_forward(naics_tree, parameters, None, None, None, True) # naics.print_tree_dfs(naics_tree, output_folder)
def get_incs(): # naics_tree = naics.generate_tree() # read_inc.load_nipa_inc_ind(data_folder, naics_tree) read_inc.load_nipa_int_ind(data_folder, naics_tree) read_inc.calc_bus_inc(naics_tree) # parameters = [read_inc.BUS_INC, read_inc.INT_INC, read_inc.FIN_INC] # naics.pop_back(naics_tree, parameters) naics.pop_forward(naics_tree, parameters) # naics.print_tree_dfs(naics_tree, output_folder) return naics_tree
def calibrate_incomes(output_data=True): """ This calibrates a tree of all the income data parameters. :param out: Whether to output the dataframes in the final tree to the output file. """ # The income directory: inc_dir = os.path.abspath(_PARAM_DIR + "\\national_income") # Importing the module for gathering and processing the income data: sys.path.append(inc_dir) import national_income as inc # Get all the income data in an income tree: inc_tree = inc.get_incs() # Output the data to the income folder inside the output folder: if output_data: inc_out_dir = os.path.abspath(_OUT_DIR + "\\income") # Make income folder if there isn't one: if not os.path.isdir(inc_out_dir): os.mkdir(inc_out_dir) # Print the data in the tree: naics.print_tree_dfs(inc_tree, inc_out_dir) return inc_tree
def load_corporate(soi_tree=naics.generate_tree(), from_out=False, get_all=False, get_tot=False, get_s=False, get_c=False, output_data=False, out_path=None): """ Loading the corporate tax soi data into a NAICS Tree. :param soi_tree: The NAICS tree to put all of the data in. :param from_out: If the corporate soi data is already in an output folder, then it can be read in directly from the output. :param get_all: Get corporate soi data for all kinds of corporations. :param get_tot: Get the aggregate soi data for corporations. :param get_s: Get the soi data for s corporations. :param get_c: Interpolate the soi data for c corporations. :param output_data: Print the corporate dataframes to csv files in the output folder. :param out_path: The output_path, both for reading in output data and for printing to the output file .. note: Because there is only data on the aggregate and s corporations, the c corporations data can only be interpolated if the other two have been calculated. """ # Initializing the output path: if out_path == None: out_path = _OUT_DIR # Initializing booleans based of initial input booleans: if get_all: get_tot = True get_s = True get_c = True if not get_tot or not get_s: get_c = False # Load the total corporate soi data into the NAICS tree: if get_tot: soi_tree = corp.load_soi_tot_corp(data_tree=soi_tree, from_out=from_out) if output_data: naics.print_tree_dfs(tree=soi_tree, out_path=out_path, data_types=[_TOT_CORP_DF_NM]) # Load the S-corporate soi data into the NAICS tree: if get_s: soi_tree = corp.load_soi_s_corp(data_tree=soi_tree, from_out=from_out) if output_data: naics.print_tree_dfs(tree=soi_tree, out_path=out_path, data_types=[_S_CORP_DF_NM]) # Calculate the C-corporate soi data for the NAICS tree: if get_c: soi_tree = corp.calc_c_corp(data_tree=soi_tree, from_out=from_out) if output_data: naics.print_tree_dfs(tree=soi_tree, out_path=out_path, data_types=[_C_CORP_DF_NM]) return soi_tree
def calibrate_incomes(output_data=True): """ This calibrates a tree of all the income data parameters. :param out: Whether to output the dataframes in the final tree to the output file. """ # The income directory: inc_dir = os.path.abspath(_PARAM_DIR + "//national_income") # Importing the module for gathering and processing the income data: sys.path.append(inc_dir) import national_income as inc # Get all the income data in an income tree: inc_tree = inc.get_incs() # Output the data to the income folder inside the output folder: if output_data: inc_out_dir = os.path.abspath(_OUT_DIR + "//income") # Make income folder if there isn't one: if not os.path.isdir(inc_out_dir): os.mkdir(inc_out_dir) # Print the data in the tree: naics.print_tree_dfs(inc_tree, inc_out_dir) return inc_tree
def load_corporate(soi_tree, from_out=False, get_all=False, get_tot=False, get_s=False, get_c=False, output_data=False, out_path=None): """ Loading the corporate tax soi data into a NAICS Tree. :param soi_tree: The NAICS tree to put all of the data in. :param from_out: If the corporate soi data is already in an output folder, then it can be read in directly from the output. :param get_all: Get corporate soi data for all kinds of corporations. :param get_tot: Get the aggregate soi data for corporations. :param get_s: Get the soi data for s corporations. :param get_c: Interpolate the soi data for c corporations. :param output_data: Print the corporate dataframes to csv files in the output folder. :param out_path: The output_path, both for reading in output data and for printing to the output file .. note: Because there is only data on the aggregate and s corporations, the c corporations data can only be interpolated if the other two have been calculated. """ # Initializing the output path: if out_path == None: out_path = _OUT_DIR # Initializing booleans based of initial input booleans: if get_all: get_tot = True get_s = True get_c = True if not get_tot or not get_s: get_c = False # Load the total corporate soi data into the NAICS tree: if get_tot: soi_tree = corp.load_soi_tot_corp(data_tree=soi_tree, from_out=from_out) if output_data: naics.print_tree_dfs(tree=soi_tree, out_path=out_path, data_types=[_TOT_CORP_DF_NM]) # Load the S-corporate soi data into the NAICS tree: if get_s: soi_tree = corp.load_soi_s_corp(data_tree=soi_tree, from_out=from_out) if output_data: naics.print_tree_dfs(tree=soi_tree, out_path=out_path, data_types=[_S_CORP_DF_NM]) # Calculate the C-corporate soi data for the NAICS tree: if get_c: soi_tree = corp.calc_c_corp(data_tree=soi_tree, from_out=from_out) if output_data: naics.print_tree_dfs(tree=soi_tree, out_path=out_path, data_types=[_C_CORP_DF_NM]) return soi_tree