generate functionThu, 30 Mar 2023

Read the dataframe called "global_dataframe" from a csv file in current directory called "Sum Data.csv". Define "KPI": returning the dataframe grouped by columns: "time" and "Volt" with mean information of columns "NEVs" and "MWhT", including a key column composer by information of columns "time" and "volt". Calculate "NtVEl" as number of different elements of dataframe grouped by the columns "time" and "Volt" of "global_dataframe". Call "KPI" for "global_dataframe" as "gKPI". Calculate "NNewInd" as round the 10% of indexes of "global_dataframe". 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.

def run_sample(NVEI, NNewInd): gKPI = KPI() NVEI = gKPI.shape[0] RdataFrame = pd.DataFrame({'absGap':[0 for i in range(1000)], 'dG1':[0 for i in range(1000)],'dG2':[0 for i in range(1000)],'dG3':[0 for i in range(1000)],'dG4':[0 for i in range(1000)],'dG5':[0 for i in range(1000)],'dG6':[0 for i in range(1000)],'dG7':[0 for i in range(1000)],'dG8':[0 for i in range(1000)],'dG9':[0 for i in range(1000)],'dG10':[0 for i in range(1000)],'dG11':[0 for i in range(1000)],'dG12':[0 for i in range(1000)],'dG13':[0 for i in range(1000)],'dG14

Questions about programming?Chat with your personal AI assistant