swdata/wos-data-2022-12-16/query.py
2023-04-04 23:12:59 +08:00

26 lines
720 B
Python

import pandas as pd
df = pd.read_excel('result.xlsx')
row_count = len(df)
counts = df.iloc[:, 4:22].apply(pd.value_counts).fillna(0).loc['👍']
users = {}
with open('result.txt', encoding='utf-8') as f:
idx = 0
username = ''
for line in f:
if line.startswith('玩家:'):
username = line.strip().split(' ')[1]
users[username] = dict(vote=0, bonus=0.0)
if line.startswith('在第') and line.strip().endswith('场比赛中获胜'):
print(df.columns[idx+4])
users[username]['vote'] += counts[idx]
idx += 1
print(row_count)
for k, v in users.items():
users[k]['bonus'] = f"{v['vote'] / counts.sum() * 1000:.2f}"
print(users)