【发布时间】:2023-03-30 11:02:01
【问题描述】:
我有一个如下所示的 Df:
tests Machine results
111 A OK
111 A OK
111 A OK
111 A NOK
111 B OK
222 A OK
333 A OK
333 B OK
444 A OK
222 A NOK
222 A OK
111 B OK
我想要一个矩阵/数据透视表,其中行应该是测试,列应该是机器,值应该是测试的比率/百分比,这对每台机器的测试总数来说是可以的。
结果应该是:
OK/total cnt A B
111 75% 100% #test 111 passed 3 out of 4 tests in machine A and all tests in B
222 50% 0% #test 222 passed 1 out of 2 tests in machine A and 0 tests prfrmd in B
333 100% 100% #test 333 passed all tests in A and B machines
请帮帮我。
【问题讨论】:
标签: python pandas pivot-table crosstab