fixing filtering
This commit is contained in:
@@ -1512,7 +1512,7 @@ def getrowdata_pl(id=0, doclean=False, convertnewtons=True,
|
||||
|
||||
|
||||
def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False, for_chart=False, compute=True,
|
||||
startenddict={}):
|
||||
startenddict={}, driveenergy=True):
|
||||
if ids:
|
||||
csvfilenames = [
|
||||
'media/strokedata_{id}.parquet.gz'.format(id=id) for id in ids]
|
||||
@@ -1520,7 +1520,9 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False,
|
||||
return pl.DataFrame()
|
||||
|
||||
data = []
|
||||
columns = [c for c in columns if c != 'None'] + ['distance', 'spm', 'workoutid','workoutstate', 'driveenergy']
|
||||
columns = [c for c in columns if c != 'None'] + ['distance', 'spm', 'workoutid','workoutstate']
|
||||
if driveenergy:
|
||||
columns = columns + ['driveenergy']
|
||||
columns = list(set(columns))
|
||||
|
||||
for id, f in zip(ids, csvfilenames):
|
||||
@@ -1583,9 +1585,10 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False,
|
||||
if len(data)==0:
|
||||
return pl.DataFrame()
|
||||
|
||||
|
||||
try:
|
||||
datadf = pl.concat(data).select(columns)
|
||||
except (SchemaError, ShapeError):
|
||||
except (ShapeError, SchemaError):
|
||||
data = [
|
||||
df.select(columns)
|
||||
for df in data]
|
||||
@@ -1593,6 +1596,7 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False,
|
||||
# float columns
|
||||
floatcolumns = []
|
||||
intcolumns = []
|
||||
stringcolumns = []
|
||||
for c in columns:
|
||||
try:
|
||||
if metricsdicts[c]['numtype'] == 'float':
|
||||
@@ -1600,7 +1604,11 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False,
|
||||
if metricsdicts[c]['numtype'] == 'integer':
|
||||
intcolumns.append(c)
|
||||
except KeyError:
|
||||
pass
|
||||
if c[0] == 'f':
|
||||
stringcolumns.append(c)
|
||||
else:
|
||||
intcolumns.append(c)
|
||||
|
||||
data = [
|
||||
df.with_columns(
|
||||
cs.float().cast(pl.Float64)
|
||||
@@ -1610,6 +1618,8 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False,
|
||||
cs.by_name(intcolumns).cast(pl.Int64)
|
||||
).with_columns(
|
||||
cs.by_name(floatcolumns).cast(pl.Float64)
|
||||
).with_columns(
|
||||
cs.by_name(stringcolumns).cast(pl.String)
|
||||
)
|
||||
for df in data
|
||||
]
|
||||
|
||||
@@ -1802,7 +1802,7 @@ def interactive_flexchart_stacked(id, r, xparam='time',
|
||||
'metrics': metrics_list,
|
||||
}
|
||||
|
||||
script, div = get_chart("/stacked", chart_data, debug=False)
|
||||
script, div = get_chart("/stacked", chart_data, debug=True)
|
||||
|
||||
return script, div
|
||||
|
||||
@@ -2129,16 +2129,20 @@ def interactive_multiple_compare_chart(ids, xparam, yparam, plottype='line',
|
||||
compute = True
|
||||
doclean = True
|
||||
|
||||
driveenergy = False
|
||||
if 'driveenergy' in columns:
|
||||
driveenergy = True
|
||||
|
||||
|
||||
datadf = pl.DataFrame()
|
||||
if promember:
|
||||
datadf = dataprep.read_data(columns, ids=ids, doclean=doclean,
|
||||
compute=compute,
|
||||
compute=compute, driveenergy=driveenergy,
|
||||
workstrokesonly=workstrokesonly, for_chart=True,
|
||||
startenddict=startenddict)
|
||||
else:
|
||||
datadf = dataprep.read_data(columns_basic, ids=ids, doclean=doclean,
|
||||
compute=compute,
|
||||
compute=compute, driveenergy = driveenergy,
|
||||
workstrokesonly=workstrokesonly, for_chart=True,
|
||||
startenddict=startenddict)
|
||||
|
||||
@@ -2165,10 +2169,10 @@ def interactive_multiple_compare_chart(ids, xparam, yparam, plottype='line',
|
||||
|
||||
if (xparam == 'time'):
|
||||
datadf = datadf.with_columns((pl.col(xparam)-datadf[0,xparam]).alias(xparam))
|
||||
|
||||
|
||||
data_dict = datadf.to_dicts()
|
||||
|
||||
metrics_list = [{'name': name, 'rowingmetrics':d } for name, d in metrics.rowingmetrics]
|
||||
metrics_list = [{'name': name, 'rowingmetrics':{k: v for k, v in d.items() if k != 'numtype_pl'} } for name, d in metrics.rowingmetrics]
|
||||
|
||||
try:
|
||||
workoutsdict = [{'id': id, 'label': labeldict[id]} for id in ids]
|
||||
@@ -2185,6 +2189,7 @@ def interactive_multiple_compare_chart(ids, xparam, yparam, plottype='line',
|
||||
'workouts': workoutsdict,
|
||||
}
|
||||
|
||||
|
||||
script, div = get_chart("/compare", chart_data, debug=False)
|
||||
return script, div
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import numpy as np
|
||||
import pandas as pd
|
||||
from scipy import optimize
|
||||
from django.utils import timezone
|
||||
from polars import String, Int32, Float64
|
||||
|
||||
from math import log10, log2
|
||||
from rowers.mytypes import otwtypes, otetypes
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
Reference in New Issue
Block a user