some error checking for invalid y metrics
This commit is contained in:
@@ -28,6 +28,7 @@ from rowingdata import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from rowers.models import Team
|
from rowers.models import Team
|
||||||
|
from rowers.metrics import axes
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import zipfile
|
import zipfile
|
||||||
@@ -899,6 +900,13 @@ def prepmultipledata(ids,verbose=False):
|
|||||||
# Read a set of columns for a set of workout ids, returns data as a
|
# Read a set of columns for a set of workout ids, returns data as a
|
||||||
# pandas dataframe
|
# pandas dataframe
|
||||||
def read_cols_df_sql(ids,columns):
|
def read_cols_df_sql(ids,columns):
|
||||||
|
# drop columns that are not in offical list
|
||||||
|
axx = [ax[0] for ax in axes]
|
||||||
|
for c in columns:
|
||||||
|
if not c in axx:
|
||||||
|
columns.remove(c)
|
||||||
|
print c,'aap'
|
||||||
|
|
||||||
columns = list(columns)+['distance','spm']
|
columns = list(columns)+['distance','spm']
|
||||||
columns = [x for x in columns if x != 'None']
|
columns = [x for x in columns if x != 'None']
|
||||||
columns = list(set(columns))
|
columns = list(set(columns))
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False):
|
|||||||
'workoutstate','driveenergy']
|
'workoutstate','driveenergy']
|
||||||
|
|
||||||
rowdata = dataprep.getsmallrowdata_db(columns,ids=ids)
|
rowdata = dataprep.getsmallrowdata_db(columns,ids=ids)
|
||||||
|
|
||||||
rowdata.dropna(axis=1,how='all',inplace=True)
|
rowdata.dropna(axis=1,how='all',inplace=True)
|
||||||
rowdata.dropna(axis=0,how='any',inplace=True)
|
rowdata.dropna(axis=0,how='any',inplace=True)
|
||||||
|
|
||||||
@@ -369,6 +370,8 @@ def interactive_histoall(theworkouts):
|
|||||||
ids = [int(w.id) for w in theworkouts]
|
ids = [int(w.id) for w in theworkouts]
|
||||||
|
|
||||||
rowdata = dataprep.getsmallrowdata_db(['power'],ids=ids,doclean=True)
|
rowdata = dataprep.getsmallrowdata_db(['power'],ids=ids,doclean=True)
|
||||||
|
|
||||||
|
|
||||||
rowdata.dropna(axis=0,how='any',inplace=True)
|
rowdata.dropna(axis=0,how='any',inplace=True)
|
||||||
|
|
||||||
if rowdata.empty:
|
if rowdata.empty:
|
||||||
@@ -802,6 +805,7 @@ def interactive_chart(id=0,promember=0):
|
|||||||
|
|
||||||
columns = ['time','pace','hr','fpace','ftime']
|
columns = ['time','pace','hr','fpace','ftime']
|
||||||
datadf = dataprep.getsmallrowdata_db(columns,ids=[id])
|
datadf = dataprep.getsmallrowdata_db(columns,ids=[id])
|
||||||
|
|
||||||
datadf.dropna(axis=0,how='any',inplace=True)
|
datadf.dropna(axis=0,how='any',inplace=True)
|
||||||
row = Workout.objects.get(id=id)
|
row = Workout.objects.get(id=id)
|
||||||
if datadf.empty:
|
if datadf.empty:
|
||||||
@@ -883,6 +887,17 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
|
|||||||
columns = [xparam,yparam1,yparam2,'spm','driveenergy','distance']
|
columns = [xparam,yparam1,yparam2,'spm','driveenergy','distance']
|
||||||
datadf = dataprep.getsmallrowdata_db(columns,ids=ids,doclean=False)
|
datadf = dataprep.getsmallrowdata_db(columns,ids=ids,doclean=False)
|
||||||
|
|
||||||
|
try:
|
||||||
|
tests = rowdata[yparam2]
|
||||||
|
except KeyError:
|
||||||
|
yparam2 = 'None'
|
||||||
|
|
||||||
|
try:
|
||||||
|
tests = rowdata[yparam1]
|
||||||
|
except KeyError:
|
||||||
|
yparam1 = 'None'
|
||||||
|
|
||||||
|
|
||||||
yparamname1 = axlabels[yparam1]
|
yparamname1 = axlabels[yparam1]
|
||||||
if yparam2 != 'None':
|
if yparam2 != 'None':
|
||||||
yparamname2 = axlabels[yparam2]
|
yparamname2 = axlabels[yparam2]
|
||||||
@@ -1167,6 +1182,16 @@ def interactive_flex_chart2(id=0,promember=0,
|
|||||||
rowdata = dataprep.getsmallrowdata_db(columns,ids=[id],doclean=True,
|
rowdata = dataprep.getsmallrowdata_db(columns,ids=[id],doclean=True,
|
||||||
workstrokesonly=workstrokesonly)
|
workstrokesonly=workstrokesonly)
|
||||||
|
|
||||||
|
try:
|
||||||
|
tests = rowdata[yparam2]
|
||||||
|
except KeyError:
|
||||||
|
yparam2 = 'None'
|
||||||
|
|
||||||
|
try:
|
||||||
|
tests = rowdata[yparam1]
|
||||||
|
except KeyError:
|
||||||
|
yparam1 = 'None'
|
||||||
|
|
||||||
rowdata.dropna(axis=1,how='all',inplace=True)
|
rowdata.dropna(axis=1,how='all',inplace=True)
|
||||||
rowdata.dropna(axis=0,how='any',inplace=True)
|
rowdata.dropna(axis=0,how='any',inplace=True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user