I have a DataFrame which is like that:
| date | Col.A | Col.B | Col.C | ... |
|---|---|---|---|---|
| 2022 | 1 | 1 | 1 | ... |
| 2023 | 2 | 2 | 2 | ... |
| 2024 | 3 | 3 | 3 | ... |
And I want to add Columns where the Diff is calculated and looks like that afterwards:
| date | Col.A | Diff Col.A | Col.B | Diff Col.B | Col.C | Diff Col.C | ... |
|---|---|---|---|---|---|---|---|
| 2022 | 1 | nan | 1 | nan | 1 | nan | ... |
| 2023 | 2 | 1 | 2 | 1 | 2 | 1 | ... |
| 2024 | 3 | 1 | 3 | 1 | 3 | 1 | ... |
I tried it like that, but it doesnt work
df = pd.read_excel('example.xlsx', header=0).set_index(['date])
df.diff()
How can I do that in Pandas