
[英]Game ranking system: Finding the people who beat the people: How do I organize this csv data and append the file?
[英]How can I use a csv file to calculate the average rating of several people in a ranking post?
有这个社区排行榜,我想我会尝试破解它。 在这个实践中,我想
import csv
import math
from collections import Counter
import pandas as pd
import sys
from collections import Counter
def main():
file = open(sys.argv[1],'r')
df = csv.DictReader(file)
newf = list(df)
gf = convert_to_float(newf)
sf = pd.DataFrame(gf)
answer = dict(sf.mean())
print(answer)
def convert_to_float(lst):
for b in lst:
for a,x in b.items():
if x.isnumeric:
result = [dict([a,float(x)]) for a,x in b.items() for b in lst]
else:
result = [dict([a,x]) for a,x in b.items()]
return result
main()
问题是,在每次回复中,没有看过角色的人都没有给他们评分,而且我很难将那个空间转换成不会影响我平均水平的东西。 通过仅使用 pandas 框架,我得到难以辨认的答案,例如1.241342432e+79
等。我完成这项任务的最简单方法是对 excel 中的所有内容进行平均,然后将最后一列放入排序算法中,但我想尝试编写代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.