I have a Dataframe where I would like to find the difference between two columns, however would like to use the column position instead of the column name when I am trying to find the difference.
Sample Dataframe:
id, purchase_date, cost, service_date
101, 01-01-2022, 101, 04-01-2022
102, 01-05-2022, 101, 03-21-2022
I would like to find the difference between purchase_date and service_date, however trying to use the column position instead of column name
I tried something like this but it failed:
df.iloc[:,1] - df.iloc[:,3]
Expect to add one more new column that would give difference in days between these two columns.