I currently have a wide row pandas dataframe with the schema
idx, user, task_0, task_1, ... , task_n, task_result_0, task_result_1 ..., task_result_n, some_other_attribute_0, some_other_attribute_1, ..., some_other_attribute_n
Each user was given the n tasks in a random order. For example
0, Bob, building-task, writing-task, reading-task, building-result, ...
1, Alice, writing-task, building-task, reading-task, writing-result, ...
Every attribute_n is related to each other. For example the information in task_0 is related to task_result_0.
I want to reorder the dataframe to give order to the tasks. So all rows look like:
0, Bob, building-task, writing-task, reading-task, building-result, ...
1, Alice, building-task, writing-task, reading-task, building-result, ...
I'm completely stumped on how to tackle this.
_0suffix, and the notation is different (dashes vs underscores). Also, do you have column headers in your input, or are you trying to sort purely by task name on each individual line? My understanding is you wish to put all tasks first and then all results after, but the same order within each set?user, task_0, task_1, ...The values don't have any common suffix. For example, a row could beBob, a,b,0.3,0.7andAlice, b,a 0.62, 0.95and should be sorted toBob, a,b,0.3,0.7andAlice ,a, b, 0.95, 0.62