我有一个part_no列表,其值如下。
[
'KH661-05782',
'ZD661-05428',
'CH661-04581',
'661-07970',
'661-07299',
'ZM661-01301',
'661-07288',
'661-02898',
'661-04582',
'KH661-05431',
'CH661-04581',
'SF661-07955',
'661-04746'
]
我想为每个值计算百分位数。所以我的输出应该像
[['ZD661-05428', 0.9545454545454546], ['CH661-04581', 0.045454545454545456]]
但是我得到这样的结果:
[['ZD661-05428', 2.9321729747481263e-06]]
用于以下代码:
vc =repair['PART_NO'].tolist()
count = len(vc) * 1.0
print [[x, vc.count(x) / count] for x in set(vc)]
答案 0 :(得分:0)
print [[i, vc.count(i) / count] for i in vc]
这解决了问题