我有一个包含以下列的数据集。
data.columns[1:]
Index(['Fraud (i.e. fabricated or falsified results)',
'Pressure to publish for career advancement',
'Insufficient oversight/mentoring by lab principal investigator (e.g. reviewing raw data)',
'Insufficient peer review of research',
'Selective reporting of results',
'Original findings not robust enough because not replicated enough in the lab publishing the work',
'Original findings obtained with low statistical power/poor statistical analysis',
'Mistakes or inadequate expertise in reproduction efforts',
'Raw data not available from original lab',
'Protocols, computer code or reagent information insufficient or not available from original lab',
'Methods need 'green fingers' – particular technical expertise that is difficult for others to reproduce',
'Variability of standard reagents', 'Poor experimental design',
'Bad luck'],
dtype='object')
而且我想使用列来做融化功能,所以我做了下面的代码。
data_melt = pd.melt(data, id_vars =['respid'], value_vars =['Fraud (i.e. fabricated or falsified results)',
'Pressure to publish for career advancement',
'Insufficient oversight/mentoring by lab principal investigator (e.g. reviewing raw data)',
'Insufficient peer review of research',
'Selective reporting of results',
'Original findings not robust enough because not replicated enough in the lab publishing the work',
'Original findings obtained with low statistical power/poor statistical analysis',
'Mistakes or inadequate expertise in reproduction efforts',
'Raw data not available from original lab',
基本上,我只是将列名粘贴到 value_vars 中。
我的问题是是否可以编写代码来实现相同的目标?
例如,只需编写如下代码。(我知道这是错误的。)
data_melt = pd.melt(data, id_vars =['respid'], value_vars = data.columns(), ,var_name = 'factor', value_name = 'rate')
谢谢!
慕沐林林
相关分类