From a506ddca8c0a661b88ebd9f267b74215a211b0fd Mon Sep 17 00:00:00 2001 From: mschwarz Date: Thu, 23 Sep 2021 14:51:36 -0600 Subject: [PATCH] Add battery props to formatter. --- marmot/marmot_h5_formatter.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/marmot/marmot_h5_formatter.py b/marmot/marmot_h5_formatter.py index cf235979..a8bbdcc1 100644 --- a/marmot/marmot_h5_formatter.py +++ b/marmot/marmot_h5_formatter.py @@ -605,6 +605,24 @@ def df_process_abatement(self): df[0] = pd.to_numeric(df[0], downcast='float') return df + def df_process_batterie(self): + """ + Method for formatting data which comes form the PLEXOS Batteries Class + + Returns + ------- + df : pd.DataFrame + Processed Output, single value column with multiindex. + + """ + df = self.df.droplevel(level=["band", "property"]) + df = pd.DataFrame(data=df.values.reshape(-1), index=df.index) + df_col = list(df.index.names) # Gets names of all columns in df and places in list + df_col.insert(0, df_col.pop(df_col.index("timestamp"))) # move timestamp to start of df + df = df.reorder_levels(df_col, axis=0) + df[0] = pd.to_numeric(df[0], downcast='float') + return df + class MarmotFormat(SetupLogger): """Main module class to be instantiated to run the formatter.