Private
Public Access
1
0

Added fillna to pace and time calculations

This commit is contained in:
sanderroosendaal
2016-11-01 10:02:10 +01:00
parent 4dd42d43c7
commit a892188e85

View File

@@ -97,8 +97,8 @@ def nicepaceformat(values):
return out
def timedeltaconv(x):
if x<=0 or x>1e9:
x=0
# if x<=0 or x>1e9:
# x=0
dt = datetime.timedelta(seconds=x)
@@ -227,7 +227,7 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
velo = thedistances/thesecs
p = pd.Series(500./velo)
p2 = p.apply(lambda x: timedeltaconv(x))
p2 = p.fillna(method='ffil').apply(lambda x: timedeltaconv(x))
source = ColumnDataSource(
data = dict(
@@ -235,7 +235,7 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
duration = thesecs,
spm = 0*theavpower,
tim = niceformat(
thesecs.apply(lambda x: timedeltaconv(x))
thesecs.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
power = theavpower,
@@ -257,7 +257,7 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
fitvelo = 500./fitp
fitpower = 2.8*(fitvelo**3)
fitt = 10**fitx/fitvelo
fitp2 = fitp.apply(lambda x: timedeltaconv(x))
fitp2 = fitp.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
sourcepaul = ColumnDataSource(
@@ -267,7 +267,7 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
power = fitpower,
spm = 0*fitpower,
tim = niceformat(
fitt.apply(lambda x: timedeltaconv(x))
fitt.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
pace = nicepaceformat(fitp2),
)
@@ -299,14 +299,14 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
fitvelo = (fitpower/2.8)**(1./3.)
fitdist = fitt*fitvelo
fitp = 500./fitvelo
fitp2 = fitp.apply(lambda x: timedeltaconv(x))
fitp2 = fitp.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
sourcecomplex = ColumnDataSource(
data = dict(
dist = fitdist,
duration = fitt,
tim = niceformat(
fitt.apply(lambda x: timedeltaconv(x))
fitt.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
spm = 0*fitpower,
power = fitpower,
@@ -339,14 +339,14 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
p = 500./velo
p2 = p.apply(lambda x: timedeltaconv(x))
p2 = p.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
source2 = ColumnDataSource(
data = dict(
duration = cpdata['Delta'],
power = cpdata['CP'],
tim = niceformat(
cpdata['Delta'].apply(lambda x: timedeltaconv(x))
cpdata['Delta'].fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
dist = cpdata['Distance'],
pace = nicepaceformat(p2),
@@ -578,10 +578,10 @@ def interactive_chart(id=0,promember=0):
t2 = t.apply(lambda x: timedeltaconv(x))
t2 = t.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
p2 = p.apply(lambda x: timedeltaconv(x))
p2 = p.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
source = ColumnDataSource(
data = dict(
@@ -779,7 +779,7 @@ def interactive_cum_flex_chart(theworkouts,promember=0,
xaxmin = x1.min()
xaxmax = 1.0e3*xaxmax
xaxmin = 1.0e3*xaxmin
x1 = x1.apply(lambda x: timedeltaconv(x))
x1 = x1.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
elif xparam=='distance':
xaxmax = x1.max()
xaxmin = x1.min()
@@ -808,7 +808,7 @@ def interactive_cum_flex_chart(theworkouts,promember=0,
if yparam1 == 'pace':
y_axis_type = 'datetime'
y1 = y1.apply(lambda x: timedeltaconv(x))
y1 = y1.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
time = thedata.ix[:,csvcolumns['time']]
@@ -854,10 +854,10 @@ def interactive_cum_flex_chart(theworkouts,promember=0,
y1=y1,
y2=y2,
time=niceformat(
time.apply(lambda x: timedeltaconv(x))
time.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
pace=nicepaceformat(
pace.apply(lambda x: timedeltaconv(x))
pace.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
hr = hr,
spm = spm,
@@ -873,10 +873,10 @@ def interactive_cum_flex_chart(theworkouts,promember=0,
y1=y1,
y2=y2,
time=niceformat(
time.apply(lambda x: timedeltaconv(x))
time.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
pace=nicepaceformat(
pace.apply(lambda x: timedeltaconv(x))
pace.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
hr = hr,
spm = spm,
@@ -1198,7 +1198,7 @@ def interactive_flex_chart2(id=0,promember=0,
if xparam=='time':
xaxmax = 1.0e3*x1.max()
xaxmin = 1.0e3*x1.min()
x1 = x1.apply(lambda x: timedeltaconv(x))
x1 = x1.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
elif xparam=='distance':
xaxmax = x1.max()
xaxmin = x1.min()
@@ -1233,7 +1233,7 @@ def interactive_flex_chart2(id=0,promember=0,
if yparam1 == 'pace':
y_axis_type = 'datetime'
y1mean = 1.0e3*y1mean
y1 = y1.apply(lambda x: timedeltaconv(x))
y1 = y1.fillna(method='ffill').fillna(method='ffill').apply(lambda x: timedeltaconv(x))
time = rowdata.df.ix[:,csvcolumns['time']]
@@ -1255,10 +1255,10 @@ def interactive_flex_chart2(id=0,promember=0,
y1=y1,
y2=y2,
time=niceformat(
time.apply(lambda x: timedeltaconv(x))
time.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
pace=nicepaceformat(
pace.apply(lambda x: timedeltaconv(x))
pace.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
hr = hr,
spm = spm,
@@ -1278,10 +1278,10 @@ def interactive_flex_chart2(id=0,promember=0,
y1=y1,
y2=y2,
time=niceformat(
time.apply(lambda x: timedeltaconv(x))
time.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
pace=nicepaceformat(
pace.apply(lambda x: timedeltaconv(x))
pace.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
hr = hr,
spm = spm,
@@ -1582,13 +1582,13 @@ def interactive_bar_chart(id=0,promember=0):
else:
TOOLS = 'pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
t2 = t.apply(lambda x: timedeltaconv(x))
p2 = p.apply(lambda x: timedeltaconv(x))
t2 = t.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
p2 = p.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
source = ColumnDataSource(
data = dict(
x=t2,
x_right = (t+time_increments).apply(lambda x:timedeltaconv(x)),
x_right = (t+time_increments).fillna(method='ffill').apply(lambda x:timedeltaconv(x)),
hr=hr,
hr_ut2=hr_ut2,
hr_ut1=hr_ut1,
@@ -1782,8 +1782,8 @@ def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm',
if xparam=='time':
x1 = x1-x1[0]
x2 = x2-x2[0]
x1 = x1.apply(lambda x: timedeltaconv(x))
x2 = x2.apply(lambda x: timedeltaconv(x))
x1 = x1.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
x2 = x2.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
x_axis_type = 'linear'
y_axis_type = 'linear'
@@ -1792,8 +1792,8 @@ def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm',
if yparam == 'pace':
y_axis_type = 'datetime'
y1 = y1.apply(lambda x: timedeltaconv(x))
y2 = y2.apply(lambda x: timedeltaconv(x))
y1 = y1.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
y2 = y2.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
ymax = 1.0e3*90
ymin = 1.0e3*180
@@ -1832,18 +1832,18 @@ def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm',
y1=y1,
y2=y2,
time1=niceformat(
time1.apply(lambda x: timedeltaconv(x))
time1.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
time2=niceformat(
time2.apply(lambda x: timedeltaconv(x))
time2.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
pace1=nicepaceformat(
pace1.apply(lambda x: timedeltaconv(x))
pace1.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
pace2=nicepaceformat(
pace2.apply(lambda x: timedeltaconv(x))
pace2.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
),
hr1 = hr1,
hr2 = hr2,
@@ -1979,10 +1979,10 @@ def interactive_otw_advanced_pace_chart(id=0,promember=0):
drivelength = savgol_filter(drivelength,windowsize,3)
rowdata.df[' DriveLength (meters)'] = drivelength
t2 = t.apply(lambda x: timedeltaconv(x))
p2 = p.apply(lambda x: timedeltaconv(x))
nowindp2 = nowindpace.apply(lambda x: timedeltaconv(x))
ergpace2 = ergpace.apply(lambda x: timedeltaconv(x))
t2 = t.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
p2 = p.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
nowindp2 = nowindpace.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
ergpace2 = ergpace.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
# Add hover to this comma-separated string and see what changes
if (promember==1):