There are 3 lists: water = [1,2,3,4,2,4,2,4,5,2,3,4,2,1,3,4,3,2,5,1] nutri = [1,2,4,6,5,6,7,5,4,5,6,7,4,3,5,5,6,5,4,3,5] mineral =[2,1,1,3,2,4,2,4,5,4,3,2,3,2,3,1,3,4,5,1,4] add them to df Pandas dataframe in the following format: index treatments value 0 0 A 25 1 1 A 30 2 2 A 28 3 3 A 36 4 4 A 29 5 0 B 45 6 1 B 55 7 2 B 29 8 3 B 56 9 4 B 40 10 0 C 30 11 1 C 29 12 2 C 33
import pandas as pd import numpy as np def func(a, b, c): a = pd.DataFrame(a) b = pd.DataFrame(b) c = pd.DataFrame(c) a['treatment'] = 'A' b['treatment'] = 'B' c['treatment'] = 'C' a['index'] = np.arange(len(a)) b['index'] = np.arange(len(b)) c['index'] = np.arange(len(c)) a = a.rename(columns={0: "value"}) b = b.rename(columns={0: "value"}) c = c.rename(columns={0: "value"}) a = a[['index', 'treatment', 'value']] b = b[['index', 'treatment', 'value']] c = c[['index', 'treatment', 'value']] d =