Lets say i have a dataframe that looks like this:
col1, col2, col3, col4
txt,c,fix,txt
txt,a,error,txt
txt,a,new,txt
txt,c,new,txt
txt,c,error,txt
txt,b,new,txt
txt,b,fix,txt
and desired output is:
col1, col2, col3, col4
txt,a,new,txt
txt,a,error,txt
txt,b,new,txt
txt,b,error,txt
txt,c,new,txt
txt,c,fix,txt
txt,c,error,txt
so col2 in ascending order, and col3 follows new->fix->error
So far I've sorted col3 with desired output with:
custom_dict = {'new': 0, 'fix': 1, 'error': 2}
csv_dataframe = csv_dataframe.sort_values(by=['col3'], key=lambda x: x.map(custom_dict))
But from my understanding using multiple columns with key does not work:
custom_dict = {'new': 0, 'fix': 1, 'error': 2}
csv_dataframe = csv_dataframe.sort_values(by=['col2', 'col3'], key=lambda x: x.map(custom_dict))
Is there a way around this, or some other implementation of key i can use to achieve desired output?