It seems simple but I can’t seem to find an efficient way to solve this in Python 3: Is there is a loop I can use in my dataframe that subtracts every column after the first column, from the first column, so that I can add that new subtracted column to a new dataframe?

Then I would like to move on to subtract every column after the second column, from the second column, and follow the same logic throughout the 18 columns where I append or add that new subtracted column to the new dataframe

Here are first 4 lines of code for the 1st and 2nd columns I am using to my dataframe (spotrates), but I have 18 columns and I know it would be easier to create a loop, and I am adding on to the end of my existing dataframe, when I want the subtracted column to be inserted to a new one.

```
spotrates['3m-on'] = spotrates.iloc[:,1] - spotrates.iloc[:,0]
spotrates['6m-on'] = spotrates.iloc[:,2] - spotrates.iloc[:,0]
spotrates['6m-3m'] = spotrates.iloc[:,2] - spotrates.iloc[:,1]
spotrates['9m-3m'] = spotrates.iloc[:,3] - spotrates.iloc[:,1]
```

Here is the definition I am trying to create, but it only solves for the difference of the first 2 columns

```
def swaps(data):
i<len(data.columns)
col1 = data.iloc[:,i]
col2 = data.iloc[:,i+1]
for col1, col2 in data.columns:
return col2 - col1
```