I have a dataframe:
'1000' '0100' '0010' '0001' '1110' '1101' '1011' '0111'
0 0 1 2 3 4 5 6 7
1 00 11 22 33 44 55 66 77
I would like to reverse the columns that their column names have their 1st and 2nd letters reversed and their 3rd and 4th as-is.
i.e.
1st col: 1000 → 2nd col: 0100
3rd col: 0010 → 5th col: 1110
4th col: 0001 → 6th col: 1101
7th col: 1011 → 8th col: 0111
I would like to have a dataframe like this:
'0100' '1000' '1110' '1101' '0010' '0001' '1011' '0111'
0 1 0 4 5 2 3 7 6
1 11 00 44 55 22 33 77 66
This is what I have for the reversion:
reversed = ''.join('1' if x == '0' else '0' for x in 1stand2ndletter)