43 lines
No EOL
1.4 KiB
Python
43 lines
No EOL
1.4 KiB
Python
import pandas as pd
|
|
import numpy as np
|
|
from ParaUtils import parse_WPS_rankings
|
|
from ParaUtils.Standards import LA2028_Events
|
|
|
|
from pathlib import Path
|
|
module_dir = Path(__file__).parent
|
|
|
|
def set_AWR(DF):
|
|
CAN = DF[DF.NPC == 'CAN']
|
|
NR4 = DF[(DF.NPC_Rank > 3) & ~DF.index.isin(CAN.index)]
|
|
pool = DF[~(DF.index.isin(CAN.index) | DF.index.isin(NR4.index))]
|
|
pool = pool.assign(AWR=pool.Seconds.apply(lambda S: 1+len(pool[pool.Seconds < S])))
|
|
return (
|
|
pd.concat([
|
|
CAN.assign(AWR='CAN'),
|
|
NR4.assign(AWR='NR > 3'),
|
|
pool
|
|
])
|
|
.sort_values('Seconds AWR'.split())
|
|
)
|
|
|
|
Current_AWR = (
|
|
pd.read_excel(module_dir / '2025 Fall Performance AWR - 2025-10-07.xlsx')
|
|
)
|
|
|
|
def find_AWR(performances,AWR=Current_AWR):
|
|
return (
|
|
performances
|
|
.astype({'SportClass':str})
|
|
.merge(
|
|
(
|
|
AWR
|
|
.pipe(lambda df: df[~df.AWR.isin('CAN|NR > 3'.split('|'))])
|
|
.pipe(lambda df: df['Gender EventClass Distance Stroke Seconds'.split()])
|
|
.rename(columns={'Seconds':'AWR'})
|
|
),
|
|
on='Gender EventClass Stroke Distance'.split(),
|
|
how='inner'
|
|
)
|
|
.groupby('Gender EventClass Stroke Distance'.split(),group_keys=False)
|
|
.apply(lambda df: df.assign(AWR=1+len(df[df.AWR < df.Seconds])).head(1))
|
|
) |