bug fix and additional filtering for spm<0
This commit is contained in:
@@ -263,6 +263,12 @@ def clean_df_stats(datadf, workstrokesonly=True, ignorehr=True,
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# protect 0 spm values from being nulled
|
||||||
|
try:
|
||||||
|
datadf['spm'] = datadf['spm'] + 1.0
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
datadf = datadf.clip(lower=0)
|
datadf = datadf.clip(lower=0)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
@@ -270,6 +276,11 @@ def clean_df_stats(datadf, workstrokesonly=True, ignorehr=True,
|
|||||||
|
|
||||||
datadf.replace(to_replace=0, value=np.nan, inplace=True)
|
datadf.replace(to_replace=0, value=np.nan, inplace=True)
|
||||||
|
|
||||||
|
# bring spm back to real values
|
||||||
|
try:
|
||||||
|
datadf['spm'] = datadf['spm'] - 1
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
|
||||||
# return from positive domain to negative
|
# return from positive domain to negative
|
||||||
try:
|
try:
|
||||||
@@ -295,6 +306,12 @@ def clean_df_stats(datadf, workstrokesonly=True, ignorehr=True,
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
mask = datadf['spm'] < 0
|
||||||
|
datadf.loc[mask,'spm'] = np.nan
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
mask = datadf['efficiency'] > 200.
|
mask = datadf['efficiency'] > 200.
|
||||||
datadf.loc[mask, 'efficiency'] = np.nan
|
datadf.loc[mask, 'efficiency'] = np.nan
|
||||||
@@ -1614,6 +1631,7 @@ def getsmallrowdata_db(columns, ids=[], doclean=True, workstrokesonly=True):
|
|||||||
if doclean:
|
if doclean:
|
||||||
data = clean_df_stats(data, ignorehr=True,
|
data = clean_df_stats(data, ignorehr=True,
|
||||||
workstrokesonly=workstrokesonly)
|
workstrokesonly=workstrokesonly)
|
||||||
|
data.dropna(inplace=True,axis=0)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|||||||
@@ -2638,18 +2638,18 @@ 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=False)
|
workstrokesonly=False)
|
||||||
workstrokesonly=False
|
workstrokesonly=False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tests = rowdata[yparam2]
|
tests = rowdata[yparam2]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
yparam2 = 'None'
|
yparam2 = 'None'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tests = rowdata[yparam1]
|
tests = rowdata[yparam1]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
yparam1 = 'None'
|
yparam1 = 'None'
|
||||||
|
|
||||||
rowdata.dropna(axis=1,how='all',inplace=True)
|
|
||||||
|
|
||||||
# test if we have drive energy
|
# test if we have drive energy
|
||||||
nowork = 1
|
nowork = 1
|
||||||
@@ -2670,7 +2670,7 @@ def interactive_flex_chart2(id=0,promember=0,
|
|||||||
|
|
||||||
row = Workout.objects.get(id=id)
|
row = Workout.objects.get(id=id)
|
||||||
if rowdata.empty:
|
if rowdata.empty:
|
||||||
return "","No valid data"
|
return "","No valid data",'','',workstrokesonly
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
rowdata.sort_values(by='time',ascending=True,inplace=True)
|
rowdata.sort_values(by='time',ascending=True,inplace=True)
|
||||||
@@ -2690,7 +2690,7 @@ def interactive_flex_chart2(id=0,promember=0,
|
|||||||
try:
|
try:
|
||||||
tseconds = rowdata.ix[:,'time']
|
tseconds = rowdata.ix[:,'time']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return '','No time data - cannot make flex plot','',''
|
return '','No time data - cannot make flex plot','','',workstrokesonly
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -3098,7 +3098,7 @@ def interactive_flex_chart2(id=0,promember=0,
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
distmax = 100+100*int(rowdata['distance'].max()/100.)
|
distmax = 100+100*int(rowdata['distance'].max()/100.)
|
||||||
except KeyError:
|
except (KeyError,ValueError):
|
||||||
distmax = 100
|
distmax = 100
|
||||||
|
|
||||||
slider_dist_min = Slider(start=0,end=distmax,value=0,step=1,
|
slider_dist_min = Slider(start=0,end=distmax,value=0,step=1,
|
||||||
|
|||||||
@@ -326,7 +326,10 @@ def wavg(group, avg_name, weight_name):
|
|||||||
should return otherwise.
|
should return otherwise.
|
||||||
"""
|
"""
|
||||||
d = group[avg_name]
|
d = group[avg_name]
|
||||||
w = group[weight_name]
|
try:
|
||||||
|
w = group[weight_name]
|
||||||
|
except KeyError:
|
||||||
|
return d.mean()
|
||||||
try:
|
try:
|
||||||
return (d * w).sum() / w.sum()
|
return (d * w).sum() / w.sum()
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
|
|||||||
@@ -7446,7 +7446,6 @@ def workout_stats_view(request,id=0,message="",successmessage=""):
|
|||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
datadf = dataprep.clean_df_stats(datadf,workstrokesonly=workstrokesonly)
|
datadf = dataprep.clean_df_stats(datadf,workstrokesonly=workstrokesonly)
|
||||||
datadf['deltat'] = datadf['time'].diff()
|
|
||||||
|
|
||||||
if datadf.empty:
|
if datadf.empty:
|
||||||
datadf,row = dataprep.getrowdata_db(id=id)
|
datadf,row = dataprep.getrowdata_db(id=id)
|
||||||
@@ -7455,6 +7454,7 @@ def workout_stats_view(request,id=0,message="",successmessage=""):
|
|||||||
if datadf.empty:
|
if datadf.empty:
|
||||||
return HttpResponse("CSV data file not found")
|
return HttpResponse("CSV data file not found")
|
||||||
|
|
||||||
|
datadf['deltat'] = datadf['time'].diff()
|
||||||
|
|
||||||
|
|
||||||
workoutstateswork = [1,4,5,8,9,6,7]
|
workoutstateswork = [1,4,5,8,9,6,7]
|
||||||
@@ -8069,15 +8069,31 @@ def workout_flexchart3_view(request,*args,**kwargs):
|
|||||||
|
|
||||||
# create interactive plot
|
# create interactive plot
|
||||||
try:
|
try:
|
||||||
script,div,js_resources,css_resources,workstrokesonly = interactive_flex_chart2(id,xparam=xparam,yparam1=yparam1,
|
(
|
||||||
yparam2=yparam2,
|
script,
|
||||||
promember=promember,plottype=plottype,
|
div,
|
||||||
workstrokesonly=workstrokesonly)
|
js_resources,
|
||||||
|
css_resources,
|
||||||
|
workstrokesonly
|
||||||
|
) = interactive_flex_chart2(
|
||||||
|
id,xparam=xparam,yparam1=yparam1,
|
||||||
|
yparam2=yparam2,
|
||||||
|
promember=promember,plottype=plottype,
|
||||||
|
workstrokesonly=workstrokesonly
|
||||||
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
script,div = interactive_flex_chart2(id,xparam=xparam,yparam1=yparam1,
|
(
|
||||||
yparam2=yparam2,
|
script,
|
||||||
promember=promember,plottype=plottype,
|
div,
|
||||||
workstrokesonly=workstrokesonly)
|
js_resources,
|
||||||
|
css_resources,
|
||||||
|
workstrokesonly
|
||||||
|
) = interactive_flex_chart2(
|
||||||
|
id,xparam=xparam,yparam1=yparam1,
|
||||||
|
yparam2=yparam2,
|
||||||
|
promember=promember,plottype=plottype,
|
||||||
|
workstrokesonly=workstrokesonly
|
||||||
|
)
|
||||||
js_resources = ""
|
js_resources = ""
|
||||||
css_resources = ""
|
css_resources = ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user