I have a df
2019 2020 2021 2022
A 10 20 30 40
I am trying to create 2 new indexes A-1 and A-2 so that the output would look like this:
2019 2020 2021 2022
A 10 20 30 40
A-1 nan 10 20 40
A-2 nan nan 10 20
I tried:
s = df.loc['A',:].shift(1, axis=0)
s = s.rename({'A': 'A-1'}, axis = 0)
df = df.combine_first(s)
But I get an error at
----> 3 df= df.combine_first(s)
ValueError: Must specify axis=0 or 1
When I add axis = 0 I get:
TypeError: combine_first() got an unexpected keyword argument 'axis'
So I am not sure where is my mistake.