def get_server_carbon_df()

in analysis/GreenSKU-Framework/src/carbon_model.py [0:0]


    def get_server_carbon_df(self) -> pd.DataFrame:
        """Get the operational and embodied carbon for the server as a dataframe."""
        operational = pd.DataFrame.from_dict(self.component_server_operational, orient='index', columns=['operational'])
        embodied = pd.DataFrame.from_dict(self.component_server_embodied, orient='index', columns=['embodied'])
        carbon = pd.DataFrame.from_dict(self.component_server_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)