I have a df that has the following structure:
ID | M | C1 | C2 | C3
tt | 23| 23 | 563| 234
rt | 13| 3 | 32 | 67
cf | 78| 67 | 90 | 90
di | 45| 12 | 112| 34
I want to iterate over columns and create additional columns as a result of the next operations:
additional_column1 = M+1+C1
additional_column2 = additional_column1+1+C2
additional_column3 = additional_column2+1+C3
So that the resulted DF will look like this:
ID | M | C1 | C2 | C3 | AC1 | AC2 | AD3
tt | 23| 23 | 563| 234| 47 | 611 | 846
I created a for loop, but instead of numbers it fills columns with at 0x7f6e81e2c5e0>
The loop looks as follows:
for c in np.arange(start=1, stop=len(df.columns[1:])+1, step=1):
df['AC'+str(c)] = lambda c: df.columns[c-1].add(0).sub(df.iloc[:, c])
Need clue, where I did a mistake. Thanks in advance.