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
def make_df(water, nutri, mineral): water = pd.DataFrame({'treatments': 'water', 'value': water}, index=list(range(len(water)))) nutri = pd.DataFrame({'treatments': 'nutri', 'value': nutri}, index=list(range(len(nutri)))) mineral = pd.DataFrame({'treatments': 'mineral', 'value': mineral}, index=list(range(len(mineral)))) df = pd.concat([water, nutri, mineral]) return df make_df(water, nutri, mineral)