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
df2 = df1.assign(col2=df1['col2'].iloc[::-1])
df1.assign(col2=df1.col2.loc[::-1].reset_index(drop=True))
actually works. If you don't reset the indices, then you will likely end up with the same dataframe.