【发布时间】:2020-07-25 03:15:14
【问题描述】:
我有一个复杂的数据框。数据框有很多按日期时间和项目划分的块。出处excel:
name sex age ID start end main data testtime item subitem result unit mark reference testman comfirmman
LSF female 60 12345678 2018-12-18 08:58 2018-12-29 08:30 knee 11
2018-12-28 13:59 metabolism II comfirm 12345678
subitem result unit mark reference
Na 142 mmol/L 135 - 145
K 3.98 mmol/L 3.50 - 5.30
Cl 105 mmol/L 96 - 110
PHOS 1.25 mmol/L 0.97 - 1.62
testman:YYY comfirmman:AAA
2018-12-28 9:57 routine blood comfirm 12345678
subitem result unit mark reference
CRP 14.72 mg/L ↑ 0.00 - 10.00
WBC 6.73 x10^9/L 4.00 - 10.00
NEUT% 0.524 0.460 - 0.750
testman:BBB comfirmman:EEE
我想将关于列索引的行更改为列。我想要什么:
name sex age ID start end main data testtime item subitem result unit mark reference testman comfirmman
LSF female 60 12345678 2018-12-18 08:58 2018-12-29 08:30 knee 11 2018-12-28 13:59 metabolism II Na 142 mmol/L 135 - 145 YYY AAA
LSF female 60 12345678 2018-12-18 08:58 2018-12-29 08:30 knee 11 2018-12-28 13:59 metabolism II K 3.98 g/L 3.50 - 5.30 YYY AAA
LSF female 60 12345678 2018-12-18 08:58 2018-12-29 08:30 knee 11 2018-12-28 13:59 metabolism II Cl 105 mmol/L 96 - 110 YYY AAA
LSF female 60 12345678 2018-12-18 08:58 2018-12-29 08:30 knee 11 2018-12-28 13:59 metabolism II PHOS 1.25 u/L 0.97 - 1.62 YYY AAA
LSF female 60 12345678 2018-12-18 08:58 2018-12-29 08:30 knee 11 2018-12-28 9:57 routine blood CRP 14.72 mg/L ↑ 0.00 - 10.00 BBB EEE
LSF female 60 12345678 2018-12-18 08:58 2018-12-29 08:30 knee 11 2018-12-28 9:57 routine blood WBC 6.73 x10^9/L 4.00 - 10.00 BBB EEE
LSF female 60 12345678 2018-12-18 08:58 2018-12-29 08:30 knee 11 2018-12-28 9:57 routine blood NEUT% 0.524 0.460 - 0.750 BBB EEE
提前感谢!
【问题讨论】: