generate functionFri, 31 Mar 2023

read the dataframe "global_dataframe" from csv file "Sum Dat.csv" group by the columns "time" and "Volt" the mean value of the columns "NVEs" and "MWhT", concatenating the values of columns "time" and "Volt"

import pandas as pd import numpy as np def load_CSV(file): global_dataframe = pd.read_csv(file) global_dataframe["time"] = global_dataframe["Date"] + " " + global_dataframe["Time"] global_dataframe["time"] = pd.to_datetime(global_dataframe["time"]) global_dataframe["time"] = global_dataframe["time"].map(lambda x: x.strftime("%Y-%m-%d %H:%M")) global_dataframe = global_dataframe.groupby(["time", "Volt"]).agg( {"NVEs": np.mean, "MWhT": np.mean}) global_dataframe = global_dataframe.reset_index() return global_dataframe load_CSV("Sum Dat.csv")

Questions about programming?Chat with your personal AI assistant