Invert a single column in a DataFrame

Viewed 7227

I do have a DataFrame mxn and would like to flip one column in similar way to list flip e.g.:

list1 = [1,2,3,4]
list2 = list1[::1]

so list2 looks like this: [4,3,2,1]

How to apply something similar to a DataFrame to a column but keep order of all rows and other columns so I flip the values in the single column only:

e.g.

df1 =

    col1    col2
1    cat     1
2    dog     2
3    fish    3
4    bird    4
5    mouse   5

to df2

    col1    col2
1    cat     5
2    dog     4
3    fish    3
4    bird    2
5    mouse   1
3 Answers
Related