There are 3 lists: water, nutri and mineral. They differ in length: print(len(water)) - 20 print(len(nutri)) -21 print(len(mineral)) -21 add them to df Pandas dataframe in the following format: index treatments value 0 0 water 25 1 1 water 30 2 2 water 28 3 3 nutri 36 4 4 nutri 29 5 0 nutri 45 6 1 mineral 55 7 2 mineral 29 8 3 mineral 56
# function to create a new data frame, water, mineral, nutri and then concatenate them to form a new df def df_maker(df, name): df['treatments'] = name df = df.reset_index() df = df[['index', 'treatments', 'value']] return df # create water df water = df_maker(water, 'water') # create nutri df nutri = df_maker(nutri, 'nutri') # create mineral df mineral = df_maker(mineral, 'mineral') # combine df combined_df = pd.concat([water, nutri, mineral]) combined_df