I have a large data frame (367 rows × 342 columns) where multiple columns have the same prefix in their name. I am trying to make our code easier to use.
Current code:
value_vars = "'Intensity 01_1',
'Intensity 01_2',
'Intensity 01_3',
'Intensity 03_1',
'Intensity 03_2',
'Intensity 03_3',
'Intensity 04_1',
'Intensity 04_2',
'Intensity 04_3',
'Intensity 05_1',
'Intensity 05_2',
'Intensity 05_3',
'Intensity 06_1',
'Intensity 06_2',
'Intensity 06_3',,
var_name="SampleMeas", value_name="SpecInt"
)
Here is what I am trying to use but I am getting an error " TypeError: unhashable type: 'list' "
valvarlist = [col for col in protstack if 'Intensity' in col],
[col for col in protstack if 'iBAQ' in col],
[col for col in protstack if 'LFQ intensity' in col]
#print(valvarlist)
test = pd.melt(protstack, id_vars="Majority protein IDs",
value_vars = valvarlist,
var_name="SampleMeas", value_name="SpecInt"
)
I have tried putting the valvarlist in [] but I get the same error. When I check type(valvarlist), I get a tuble, which should be usable with melt.