This commit is contained in:
John Gatward
2026-03-19 21:43:34 +00:00
parent f0a6dd85a6
commit 80a66bc44c
7 changed files with 588 additions and 317 deletions
+19 -14
View File
@@ -1,20 +1,25 @@
from constants import PLAYER_NAME_COLUMNS
from constants import PLAYER_NAME_COLUMNS, ordinal
def generate_player_table(df):
header = [["Name", "Appearances", "Spent"]]
header = [["Player", "Appearances", "Avg. Relative Percentile", "Spent"]]
player_stats = []
for name in PLAYER_NAME_COLUMNS:
if name in df.columns:
attended = df[df[name] == 1]
n = len(attended)
if n > 0:
avg_rel = attended["Relative Position"].mean()
player_stats.append((name, n, avg_rel))
player_stats = [
(name, df[name].sum())
for name in df.columns
if name in PLAYER_NAME_COLUMNS
]
player_stats.sort(key=lambda x: x[1], reverse=True)
total = sum(n for name, n in player_stats)
body = [
[name, n, f"£{n * 3:.2f}"]
for name, n in player_stats
]
footer = [["Total", total, f"£{total * 3:.2f}"]]
total = sum(n for _, n, _ in player_stats)
return (header + body + footer)
body = [
[name, n, ordinal(round(avg_rel * 100)), f"£{n * 3:.2f}"]
for name, n, avg_rel in player_stats
]
footer = [["Total", total, "", f"£{total * 3:.2f}"]]
return header + body + footer