generate functionThu, 30 Mar 2023

Define the function "KPI" for dataframe grouped by columns "time" and "Volts" (concatenating them using the column name as delimiters) for mean data of columns "NEVs" and "MWht". Define the dataframe "RdataFrame" with columns: - "absGap" - "dG1", "dG2", "dG3",etc. With "NVEI" columns. - "Id1","Id2","Id3", etc. With "NNewInd" columns. For the first 2 indexes of "RdataFrame", in the columns "dG1", "dG2", etc. Put the information of the columns: "time" and "Volt" of "gKPI" in 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 list "Indexes" of indexes choosen transposed. - Call "KPI" for "SDFrame" as "sKPI". - Calculate absolute error, "absGap", and detailed error per "Volt" value, "detGap", between "sKPI" and "gKPI". - Store "absGap" and "detGap" in the dataframe "RdataFrame" in columns "aGap", "dG1", "dG2", "dG3",etc. - Store "Indexes" in the dataframe "RdataFrame" in the columns "Id1","Id2","Id3",etc.

RdataFrame=pd.DataFrame(columns=["absGap"]+["dG"+str(i) for i in range(1,NVEI+1)]+["Id"+str(i) for i in range(1,NNewInd+1)]) def KPI(df): return df.groupby(by=["Time","Volt"]).mean()[["NEVs","MWht"]] for Sample in range(1000): SDFrame=global_dataframe.sample(frac=0.1) Indexes=SDFrame.index.values.reshape(NNewInd,1) sKPI=KPI(SDFrame) absGap=abs(gKPI.sum().sum()-sKPI.sum().sum()) detGap=[abs(gKPI.sum().sum()-sKPI[i].sum().sum()) for i in range(1,NVEI+1)] RdataFrame.loc[len(RdataFrame)]=[absGap]+detGap+[Index

Questions about programming?Chat with your personal AI assistant