I have this python list:
['Intercept', 'a', 'country[T.BE]', 'country[T.CY]', 'country[T.DE]', 'b', 'c', 'd', 'e']
I want the country items at the end:
['Intercept', 'a', 'b', 'c', 'd', 'e', 'country[T.BE]', 'country[T.CY]', 'country[T.DE]']
How to accomplish this?
(Note, the items are column headers of a dataframe that I will use for regression analysis. The column names and the weird ordering are generated by patsy.dmatrices.)
I tried sorting, pop, del, and list comprehension, but to no avail. In this case I decided not to explain what I did to solve this problem and did not work. It is a simple problem, and unlike one commentators, I do not have decades of programming experience.