generate functionWed, 29 Mar 2023

Read the dataframe called "global_dataframe" from a csv file in current directory called "Sum Data.csv". Define "KPI": Grouping the dataframe by column "Volt" and get mean information of columns "NEVs" and "MWhT". Execute "KPI" for "global_dataframe" as "gKPI". Calculate "NNewInd" as round the 10% of indexes of "global_dataframe". Calculate "NVEl" as number of different elements in the column "Volts" of "global_dataframe". Define the dataframe "RdataFrame" with columns: - "absGap" - "dG1", "dG2", "dG3",etc. With "NVEI" columns. - "Id1","Id2","Id3", etc. With "NNewInd" columns. Start a loop of 1000 "Sample" in "Samples", per each sample: - Get sub dataframe "SDFrame" componed by 10% of the indexes of "global_dataframe" choosen randomly, Store the indexes choosen transposed in the dataframe "RdataFrame" in the columns "Id1","Id2","Id3",etc. - Execute "KPI" for "SDFrame" as "sKPI". - Calculate absolute error, "absGap", and detailed error, "detGap", between "sKPI" and "gKPI". - Store "absGap" and "detGap" in the dataframe "RdataFrame" in columns "aGap", "dG1", "dG2", "dG3",etc.

def readDataFrame(): global global_dataframe global_dataframe = pd.read_csv('Sum Data.csv', sep=';', decimal=',') def KPI(): return global_dataframe.groupby(["Volt"]).mean()[["NEVs", "MWhT"]] def executeKPI(df): return df.groupby(["Volt"]).mean()[["NEVs", "MWhT"]] def getNNewInd(): return round(global_dataframe.shape[0] * 0.1) def getNVEI(): return len(global_dataframe.Volt.unique()) def calcGap(m1, m2): return abs(m1 - m2) def calcDetGap(m1, m2): res = np.zeros(getNVEI()) for idx in range(getNVEI()): res[idx] = abs(m1.iloc[idx, 0] - m

Questions about programming?Chat with your personal AI assistant