I have a dataframe of 3*1 dimensions. The dataframe looks like the following:
weights
0 4
1 13
2 91
I want to make the dataframe upside down like the following:
weights
0 91
1 13
2 4
How can I do that?
CodePudding user response:
You can convert the column to a numpy array and use an slice with a step of -1
to reverse:
df['weights'] = df['weights'].to_numpy()[::-1]
Output:
>>> df
weights
0 91
1 13
2 4