This commit is contained in:
edeymc 2025-11-05 18:52:56 -08:00
parent 6d1ed90997
commit 47f891ef41

View file

@ -1,4 +1,7 @@
#Bits and bobs used for many different projects. Junk drawer module
import pandas
import numpy
#Useful functions for parsing race-like durations, and normalizing their string reps
def t2f(S):
@ -6,7 +9,7 @@ def t2f(S):
return None
m,s = ('0:%s' % S).split(':')[-2:]
try:
return np.round(60*int(m) + float(s),2)
return numpy.round(60*int(m) + float(s),2)
except:
return -1
@ -21,7 +24,7 @@ def f2t(S):
return f'{m:02}:{s:02}.{round(hs*100):02}'
#Canada Summer Games eligible events
CSG = pd.DataFrame([
CSG = pandas.DataFrame([
{'Stroke':'Butterfly','Distance':50,'SportClass':[1,2,3,4,5,6,7]},
{'Stroke':'Butterfly','Distance':100,'SportClass':[8,9,10,11,12,13,14]},
{'Stroke':'Backstroke','Distance':50,'SportClass':[1,2,3,4,5]},
@ -37,7 +40,7 @@ CSG = pd.DataFrame([
]).explode('SportClass').reset_index(drop=True)
def parse_WPS_rankings(DF):
'''Takes a pandas datafram, usually loaded from an excel file, and cleans it up for use'''
'''Takes a pandas dataframe, usually loaded from an excel file, and cleans it up for use'''
return (
DF
#Makes .dot notation easier
@ -58,3 +61,7 @@ def parse_WPS_rankings(DF):
#Drop excess columns
.pipe(lambda df: df['Gender SportClass Distance Stroke Result Seconds SDMS_ID NPC Given_Name Family_Name Date'.split()])
)
__version__ = "0.1"