1 回答
TA贡献2016条经验 获得超9个赞
这是一个解决方案:
# Create a dummy dataframe with columns similar to yours.
df = pd.DataFrame({"respid": range(5),
"Fraud (i.e. fabricated or falsified results)": range(5,10),
'Pressure to publish for career advancement': range(10, 15),
'Insufficient oversight/mentoring by lab principal investigator (e.g. reviewing raw data)': range(15,20),
'Insufficient peer review of research': range(20,25)
})
pd.melt(df, id_vars =['respid'], value_vars=set(df.columns).difference(["respid"]))
结果是:
respid variable value
0 0 Fraud (i.e. fabricated or falsified results) 5
1 1 Fraud (i.e. fabricated or falsified results) 6
2 2 Fraud (i.e. fabricated or falsified results) 7
3 3 Fraud (i.e. fabricated or falsified results) 8
4 4 Fraud (i.e. fabricated or falsified results) 9
5 0 Insufficient peer review of research 20
6 1 Insufficient peer review of research 21
7 2 Insufficient peer review of research 22
8 3 Insufficient peer review of research 23
...
添加回答
举报