Private
Public Access
1
0

boxchart pandas to polars

This commit is contained in:
2024-04-13 17:19:47 +02:00
parent acf5e401df
commit 5d8968fc5f
3 changed files with 15 additions and 28 deletions

View File

@@ -927,28 +927,18 @@ def boxplotdata(workouts, options):
ids = [w.id for w in workouts]
# prepare data frame
datadf, extracols = dataprep.read_cols_df_sql(ids, fieldlist)
datadf = getsmallrowdata_pl(fieldlist, ids)
datadf = dataprep.clean_df_stats(datadf, workstrokesonly=workstrokesonly)
datadf = dataprep.clean_df_stats_pl(datadf, workstrokesonly=workstrokesonly)
datadf = dataprep.filter_df(datadf, 'spm', spmmin,
largerthan=True)
datadf = dataprep.filter_df(datadf, 'spm', spmmax,
largerthan=False)
datadf = dataprep.filter_df(datadf, 'driveenergy', workmin,
largerthan=True)
datadf = dataprep.filter_df(datadf, 'driveneergy', workmax,
largerthan=False)
datadf = datadf.filter(
pl.col("spm")>spmmin,
pl.col("spm")<spmmax,
pl.col("driveenergy")>workmin,
pl.col("driveenergy")<workmax,
)
datadf.dropna(axis=0, how='any', inplace=True)
datadf = datadf[datadf['workoutid'].isin(ids) == True]
datadf['workoutid'].replace(datemapping, inplace=True)
datadf.rename(columns={"workoutid": "date"}, inplace=True)
datadf['date'] = pd.to_datetime(datadf['date'], errors='coerce')
datadf = datadf.dropna(subset=['date'])
datadf = datadf.sort_values(['date'])
datadf = datadf.with_columns((pl.col("workoutid").apply(lambda x: datemapping[x])).alias("date"))
if userid == 0: # pragma: no cover
extratitle = ''
@@ -958,7 +948,7 @@ def boxplotdata(workouts, options):
savedata = options.get('savedata',False)
if savedata: # pragma: no cover
return datadf
return datadf.to_pandas()
script, div = interactive_boxchart(datadf, plotfield,
extratitle=extratitle,