这是一个数据框:
test_num file_num dose is_anneal test_name fail
0 10 0 0.00 False test1
1 10 1 10.42 False test1
2 10 2 34.34 False test1
3 10 3 57.06 False test1
4 10 4 103.45 False test1
5 10 5 200.69 False test1
6 10 6 300.24 False test1 8↑
7 11 0 0.00 False test2
8 11 1 10.42 False test2
9 11 2 34.34 False test2
10 11 3 57.06 False test2 2↑
11 11 4 103.45 False test2 2↑
12 11 5 200.69 False test2 2↑
13 11 6 300.24 False test2 2↑,8↑
我想制作一个数据透视表,以便test_num
和test_name
都可以出现:
fail_data_pivot = fd.pivot(columns='dose', index=['test_num', 'test_name'], values='fail')
>>ValueError: Wrong number of items passed 14, placement implies 2
fail_data_pivot = fd.pivot_table(columns='dose', index=['test_num', 'test_name'], values='fail')
>>pandas.core.base.DataError: No numeric types to aggregate
如果我只留下test_num
,那么它会起作用:
fail_data_pivot = fd.pivot(columns='dose', index='test_num', values='fail')
print(fail_data_pivot)
dose 0.00 10.42 34.34 57.06 103.45 200.69 300.24
test_num
10 8↑
11 2↑ 2↑ 2↑ 2↑,8↑
这是我想要的:
dose 0.00 10.42 34.34 57.06 103.45 200.69 300.24
test_num test_name
10 test1 8↑
11 test2 2↑ 2↑ 2↑ 2↑,8↑
如何制作具有多个索引的数据透视表?
答案 0 :(得分:1)
正如我所说,您可以使用>>> from ecc import curves
>>> curve = curves.P256()
>>> pkey = 0x00c3f7c39a9be2418cd89a732e40d648b09fa0af9e909a4fb6864910144b5cbcdf
>>> s1 = c.sign(b'Hello', pkey)
(37527198291707833181859423619289327687028014812888685671525882103189540525356,7717531609084222009133798505588038563850333231389727023073200992747312618427)
>>> s2 = c.sign(b'Hello', pkey)
(55880701658034823360120047989457771316451459626784083177171213563603884569397,88917360761747520665103257272757357544674490240888454865713640275762122369837)
>>> s1 == s2
False
pivot_table