【发布时间】:2015-10-04 04:10:11
【问题描述】:
我有一个这样的熊猫数据框
snapDate instance waitEvent AvgWaitInMs
0 2015-Jul-03 XX gc cr block 3-way 1
1 2015-Jun-29 YY gc current block 3-way 2
2 2015-Jul-03 YY gc current block 3-way 1
3 2015-Jun-29 XX gc current block 3-way 2
4 2015-Jul-01 XX gc current block 3-way 2
5 2015-Jul-01 YY gc current block 3-way 2
6 2015-Jul-03 XX gc current block 3-way 2
7 2015-Jul-03 YY log file sync 9
8 2015-Jun-29 XX log file sync 8
9 2015-Jul-03 XX log file sync 8
10 2015-Jul-01 XX log file sync 8
11 2015-Jul-01 YY log file sync 9
12 2015-Jun-29 YY log file sync 8
我需要把它转换成
snapDate instance gc cr block 3-way gc current block 3-way log file sync
2015-Jul-03 XX 1 Na 8
2015-Jun-29 YY Na 2 8
2015-Jul-03 YY Na 1 9
...
我尝试了 pivot 但它返回一个错误 dfWaits.pivot(索引 = 'snapDate',列 = 'waitEvent',值 = 'AvgWaitInMs') 索引包含重复条目,无法重塑
结果应该是另一个数据帧
【问题讨论】: