I'm facing a problem while trying to rearrange a column based on a custom list. for example: A sample of my dataframe is:
test_df = pd.DataFrame({'ID':[1,2,3,4,5],'Country Code':['US','DE','SE','CH','AT']})
test_df
And I have the list as:
list_country_code = ['DE','SE','AT','UK']
Now, what I want is that the dataframe should be rearranged in the order specified within the list. So, the desired output for this is:
As you can see here, the Country Code column of the dataframe is rearranged in order of the list. It may happen that any element is present in the list and not in the column and vice versa, and in that case we can just have it at the end of the dataframe.
I've tried to use sort_values() using this list but no luck until now. How can I move forward with this?

