I\'m trying to swap the rows within the same DataFrame in pandas.
I\'ve tried running
a = pd.DataFrame(data = [[1,2],[3,4]], index=range(2), columns
In this way, it can be extrapolated to more complex situations:
a = pd.DataFrame(data = [[1,2],[3,4]], index=range(2), columns = ['A', 'B']) rows = a.index.tolist() rows = rows[-1:]+rows[:-1] a=a.loc[rows]