Skip to content

Commit

Permalink
Some more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeee committed Oct 29, 2024
1 parent 40481e9 commit e42e744
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions resources/data/dictionary/utils/generate_column_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def convert_annual_col(col):
if col.startswith("build_existing_model."):
if col == "build_existing_model.sample_weight":
return "weight", "", 1.0
return col.replace("build_existing_model.", "in."), "", 1.0
return col.replace("build_existing_model.", "in."), None, None
if m1 := endues_energy_col_re.match(col):
fuel_or_end, fueltype, enduse, fuelunits = m1.groups()
newcol = shrink_colname(f"out.{fueltype}.{enduse}.energy_consumption")
Expand Down Expand Up @@ -221,7 +221,7 @@ def convert_ts_col(col):
return new_col, "C", 1.0
return None, None, None


# Read inputs.csv and outputs.csv
here = pathlib.Path(__file__).parent.parent
inputs_df = pl.read_csv(here / 'inputs.csv')
inputs_df = inputs_df.select(
Expand All @@ -238,6 +238,7 @@ def convert_ts_col(col):
converted_annual_col = {col: convert_annual_col(col) for col in outputs_df['Annual Name'].to_list()}
converted_ts_col = {col: convert_ts_col(col) for col in outputs_df[str_res_ts_name].to_list()}

# Add published annual and timeseries columns and their unit conversion factors
outputs_df2 = outputs_df.select(
pl.col(str_column_type),
pl.col(str_res_annual_name),
Expand Down Expand Up @@ -268,12 +269,13 @@ def convert_ts_col(col):
outputs_df2 = pl.concat(items=[outputs_df2, new_df], how='diagonal')

# Add other miscelleneus columns
# 'in.representative_income', 'in.county_name', 'out.energy_burden.percentage'
misc_df = pl.DataFrame({
str_column_type: ['Calculated'] * 3,
str_pub_annual_name: ['in.representative_income', 'in.county_name', 'out.energy_burden.percentage'],
str_pub_annual_unit: ['usd', '', 'percentage'],
str_notes: ['Average representative income of the country',
str_column_type: ['Calculated'] * 5,
str_pub_annual_name: ['upgrade', 'applicability', 'in.representative_income', 'in.county_name', 'out.energy_burden.percentage'],
str_pub_annual_unit: [None, None, 'usd', None, 'percentage'],
str_notes: ['The upgrade number',
'Whether the upgrade is applicable to the building. Will be always True for baseline.',
'Average representative income of the country',
'County name',
'Percentage of income spent on energy']
})
Expand Down

0 comments on commit e42e744

Please sign in to comment.