I have the below dataframe:
id a b
1 1 5
2 -5 0
3 0 5
4 5 6
and I am trying to duplicate the first and last row of the dataframe:
id a b
1 1 5
1 1 5
2 -5 0
3 0 5
4 5 6
4 5 6
I have many data frames in the list so I am trying to using this code:
for df in list:
pd.concat([df.head(1), df], axis=1)
pd.concat([df.tail(1), df], axis=1)
It is not working, can anyone help me solve it?