我遇到了一个问题。我有一个如下的数据帧:
test_index test-item test_value
Serial_Number
SN_0 1 A A-0.1
SN_0 1 B B-0.1
SN_0 2 A A-0.2
SN_0 2 B B-0.2
SN_1 3 A A-0.3
SN_1 3 B B-0.3
SN_1 4 A A-0.4
SN_1 4 B B-0.4
SN_3 5 A A-0.5
SN_3 5 B B-0.5
SN_3 6 A A-0.6
SN_3 6 B B-0.6
我想得到如下的数据帧:
Serial_Number test_index A B
SN_0 1 A-0.1 B-0.1
SN_0 2 A-0.2 B-0.2
SN_1 3 A-0.3 B-0.3
SN_1 4 A-0.4 B-0.4
SN_3 5 A-0.5 B-0.5
SN_3 6 A-0.6 B-0.6
我试过dataframe.unstack()
,dataframe.reset_index()
,但失败了。你知道吗
可以将^{} 与} 。然后使用^{} 和^{} 清理格式。你知道吗
append=True
参数组合使用,然后使用^{注意-我相信
droplevel
是一个pandas0.24.0
或更高版本的方法,所以这需要一个最新版本的pandas。你知道吗[输出]
相关问题 更多 >
编程相关推荐