generate functionWed, 29 Mar 2023

Read the dataframe "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". Start a loop of 1000 "Sample" in "Samples". Per each "Sample": 1. 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. 2. Execute "KPI" for "SDFrame" as "sKPI". 3. Calculate absolute error, "absGap", and detailed error, "detGap", between "sKPI" and "gKPI". 4. Store "absGap" and "detGap" in the dataframe "RdataFrame" in columns "aGap", "dG1", "dG2", "dG3",etc.

def read_data(): global global_dataframe global_dataframe = pandas.read_csv("Sum Data.csv") def KPI(df): sdf = df.groupby(["Volt"])["NEVs","MWhT"].mean() sdf.reset_index(level=0, inplace=True) return sdf def do_something(): RdataFrame = pandas.DataFrame(columns=("Id1","Id2","Id3","Id4", "Id5", "Id6", "Id7", "Id8", "Id9", "Id10", "aGap", "dG1", "dG2", "dG3","dG4", "dG5", "dG6", "dG7", "dG8", "dG9", "dG10")) gKPI = KPI(global_dataframe) gKPI.set_index("Volt", inplace=True) Samples = 1000 for i in range(Samples):

Questions about programming?Chat with your personal AI assistant