4.11. get_context_data module

class get_context_data.GetFuelPrices(input_file, aeo_case, id_col, *fuels)[source]

Bases: object

The GetFuelPrices class grabs the appropriate fuel prices from the aeo folder, cleans up some naming and creates a fuel_prices DataFrame for use in operating costs.

Parameters:

input_file: String; the file containing fuel price data.

aeo_case: String; from the General Inputs sheet - the AEO fuel case to use (a CSV of fuel prices must exist in the aeo directory).

id_col: String; the column name where id data can be found.

fuels: String(s); the AEO descriptor for the fuel prices needed in the project (e.g., Motor Gasoline, Diesel).

Note:

This class assumes a file structured like those published by EIA in the Annual Energy Outlook.

aeo_dollars()[source]
Returns:

An integer value representing the dollar basis of the AEO report.

select_aeo_table_rows(df_source, row)[source]
Parameters:

df_source: DataFrame; contains the AEO fuel prices.

row: String; the specific row to select.

Returns:

A DataFrame of the specific fuel price row.

row_dict(fuel)[source]
Parameters:

fuel: String; the fuel (gasoline/diesel).

Returns:

A dictionary of fuel prices.

melt_df(df, value_name)[source]
Parameters:

df: DataFrame; the fuel prices to melt.

value_name: String; the name of the melted values.

Returns:

A DataFrame of melted value_name data by year.

get_prices()[source]
Returns:

A DataFrame of fuel prices for the given AEO case. Note that CNG prices are set equivalent to gasoline prices.

class get_context_data.GetDeflators(input_file, id_col, id_value)[source]

Bases: object

The GetDeflators class returns the GDP Implicit Price Deflators for use in adjusting monetized values to a consistent cost basis.

Parameters:

input_file: String; the file containing price deflator data.

id_col: String; the column name where id data can be found.

id_value: the value within id_col to return.

Note:

This class assumes a file structured like those published by the Bureau of Economic Analysis.

deflator_df()[source]
Returns:

A DataFrame consisting of only the data for the given AEO case; the name of the AEO case is also removed from the ‘full name’ column entries.

melt_df(value_name, drop_col=None)[source]
Parameters:

value_name: String; the name for the resultant data column.

drop_col: String; the name of any columns to be dropped after melt.

Returns:

The melted DataFrame with a column of data named value_name.

calc_adjustment_factors(dollar_basis)[source]
Parameters:

dollar_basis: Numeric; the dollar basis for the analysis set via the General Inputs sheet.

Returns:

A dictionary of deflators and adjustment_factors to apply to monetized values to put them all on a consistent dollar basis.