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
import pandas as pd water = [25,30,28,24,34] nutri = [36,29,45,23,30,39,28] mineral = [55,29,56,20] df = pd.DataFrame() df['index'] = list(range(len(water)+len(nutri)+len(mineral))) df['treatment'] = list(water) + list(nutri) + list(mineral) df['treatment'] = df['treatment'].replace(water, "water") df['treatment'] = df['treatment'].replace(nutri, "nutri") df['treatment'] = df['treatment'].replace(mineral, "mineral") df