in analysis/GreenSKU-Framework/src/carbon_model.py [0:0]
def get_dc_carbon_df(self) -> pd.DataFrame:
"""Get the operational and embodied carbon for the data center as a dataframe."""
operational = pd.DataFrame.from_dict(self.component_dc_operational, orient='index', columns=['operational'])
embodied = pd.DataFrame.from_dict(self.component_dc_embodied, orient='index', columns=['embodied'])
carbon = pd.DataFrame.from_dict(self.component_dc_carbon, orient='index', columns=['carbon'])
# add totals
operational.loc['total'] = operational.sum()
embodied.loc['total'] = embodied.sum()
carbon.loc['total'] = carbon.sum()
# calculate percentages of total
operational['perc of operational'] = operational['operational'] * 100 / operational.loc['total', 'operational']
embodied['perc of embodied'] = embodied['embodied'] * 100 / embodied.loc['total', 'embodied']
carbon['perc of carbon'] = carbon * 100 / carbon.loc['total', 'carbon']
# round to 2 decimal places
operational = operational.round(2)
embodied = embodied.round(2)
carbon = carbon.round(2)
# concat them as columns
return pd.concat([operational, embodied, carbon], axis=1)