From 5d8968fc5fa33ec62712d0df2f92891b47ce24c7 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 13 Apr 2024 17:19:47 +0200 Subject: [PATCH] boxchart pandas to polars --- rowers/interactiveplots.py | 13 +++++------ rowers/tests/testdata/testdata.tcx.gz | Bin 4000 -> 4001 bytes rowers/views/analysisviews.py | 30 +++++++++----------------- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index 1f8a073f..6f2b42e0 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -328,7 +328,7 @@ def interactive_workouttype_piechart(workouts): def interactive_boxchart(datadf, fieldname, extratitle='', spmmin=0, spmmax=0, workmin=0, workmax=0): - if datadf.empty: # pragma: no cover + if datadf.is_empty(): # pragma: no cover return '', 'It looks like there are no data matching your filter' columns = datadf.columns @@ -339,20 +339,17 @@ def interactive_boxchart(datadf, fieldname, extratitle='', if 'date' not in columns: # pragma: no cover return '', 'Not enough data' - try: - datadf.date = datadf.date.apply(lambda x:x.strftime("%Y-%m-%d")) - except AttributeError: - datadf.date = "2000-01-01" + datadf = datadf.with_columns((pl.col("date").apply(lambda x:x.strftime("%Y-%m-%d"))).alias("date")) + datadf = datadf.with_columns((pl.col(fieldname)).alias("value")) - datadf['value'] = datadf[fieldname] - data_dict = datadf.to_dict("records") + data_dict = datadf.to_dicts() boxplot_data = { "metric": metricsdicts[fieldname]["verbose_name"], "data": data_dict } - script, div = get_chart("/boxplot", boxplot_data) + script, div = get_chart("/boxplot", boxplot_data, debug=False) return script, div diff --git a/rowers/tests/testdata/testdata.tcx.gz b/rowers/tests/testdata/testdata.tcx.gz index 96809caca2971e112783a06ee9e4fc7fc5cc2180..0873ae7aafdc85f8930c098d869ebd25fb92fe0e 100644 GIT binary patch delta 257 zcmV+c0sj7=AE6%xABzYGMpv;0s}6q`?D6m5@C3d(?Y}u(><)OaJJTP(F@L`PwAy`t z`1mSuytw+X?~5+IJy#cRH{JTAJ3HGxt@LrVK0WFBE}ggAyIiu!NANSjCxPG*so&WG(-}FpB(-0BD2~4x!e9@ zdW&DYKL2f*?hN1|!0!LU#f>j^Pk#HDjvj1Luh!`~JWeQ=S5MN@_$^)f=)wO0Dd@J= H#DD<+oo177 delta 256 zcmV+b0ssD?AD|xwABzYGuvD=Is}6rS;SintZsDub{+q+a?tlloGyU-!^XKbNtKIj9 zkFOHPi>nX&zUb21b9M1{)2&asv$O5fN*`D2)03|6(s{ex+m)z%Jnrz(>;Bcn)s5HW z(dFgY>bUFEPrrUKuFw6&$so(()*YWz4359Yqq<9`43;Fn?Cw!dA95}%fumn`tay(+}Gi=ZhiXn$spmmin, + pl.col("spm")workmin, + pl.col("driveenergy")