generate functionSat, 01 Apr 2023

dataframe "global_dataframe". Read information "Indexes" in a dataframe for the index [0] in the columns "Id1", "Id2", "Id3", etc. with 12 columns. Geta subDataFrame from "global_dataframe" containing only the information of indexes in "Indexes"

df = pd.DataFrame({'Id1': ['A', 'B', 'C', 'D', 'E'], 'Id2': ['F', 'G', 'H', 'I', 'J'], 'Id3': ['K', 'L', 'M', 'N', 'O']}) #print(df) def selectRows(inDataFrame, indexes): indexNames = indexes #print(indexNames) df2 = inDataFrame.loc[indexNames] return(df2) Indexes = ["0", "3"] df3 = selectRows(df, Indexes) print(df3)

Questions about programming?Chat with your personal AI assistant