0

I want my for loop to dynamically update the value for "change in NWC"

#add new column for the change in NWC df["Change_in_NWC"] = 0 #value of new row = value for "wcap" this minus value "wcap" from previous row for row in range(len(df)): df.iloc[row]["Change_in_NWC"] = df.iloc[row]["wcap"]-df.iloc[row-1]["wcap"]

I needed the values to dynamically update which they did not.

0 Answers0