I am trying to remove an existing pandas framework.
I have a csv file that I import and look something like this (this is a simplified version):
trial_num trial_name unit_1_act unit_2_act unit_3_act unit_4_act
0 face 0.0 0.000000 0.272244 0.006428
1 face 0.0 0.000000 0.898450 0.000000
2 face 0.0 0.893845 0.000000 0.000000
3 scene 0.0 0.879367 0.000000 0.006312
4 scene 0.0 0.000000 0.000000 0.000000
In this form, I have several observations in each row (each "unit_X_act" is a separate observation.) I want to separate them so that there is one observation per row.
In other words, I would like to change this so that instead of columns called "unit_1_act", "unit_2_act", etc. I would have the following: one column called "unit number" for which the value can be "unit_1", "unit_2", etc., and then one column called "activity", which has a value that was previously under each column is unit_X_act.
source
share