pasztora
11/12/2019 - 1:14 PM

Creating df columns in a loop

# Creating new dataframe columns with a loop and calculating the pure lactose amounts based on the list of concentrations
lactose_conc = [39.0, 45.0, 47.0]

for i in range(len(lactose_conc)):
    df["Pure lac [kg] " + str(lactose_conc[i]) + "%"] = df.iloc[:, i] / 100 * lactose_conc[i]