From 0b2fc89ffbec2a0a3498db75e44b0dc6cc68fb4e Mon Sep 17 00:00:00 2001 From: sanderroosendaal Date: Mon, 31 Oct 2016 15:32:53 +0100 Subject: [PATCH] added check for non-empty dataframe --- rowers/interactiveplots.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index 2683ebfd..853d94e3 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -793,10 +793,18 @@ def interactive_cum_flex_chart(theworkouts,promember=0, if yparam2 != 'None': thedata = thedata[thedata[csvcolumns[yparam2]] > 0] + # check if dataframe not empty + if thedata.empty: + return ['','

No non-zero data in selection

','',''] + spm = thedata.ix[:,csvcolumns['spm']] f = thedata['TimeStamp (sec)'].diff().mean() - windowsize = 2*(int(10./(f)))+1 + if not np.isnan(f): + windowsize = 2*(int(10./(f)))+1 + else: + windowsize = 5 + if windowsize <= 3: windowsize = 5 @@ -825,8 +833,8 @@ def interactive_cum_flex_chart(theworkouts,promember=0, if xparam=='time': xaxmax = x1.max() xaxmin = x1.min() - xaxmax = get_datetimes([x1.max()])[0] - xaxmin = get_datetimes([x1.min()])[0] + xaxmax = get_datetimes([xaxmax],tzinfo=1)[0] + xaxmin = get_datetimes([xaxmin],tzinfo=1)[0] x1 = get_datetimes(x1,tzinfo=1) elif xparam=='distance': xaxmax = x1.max() @@ -1554,7 +1562,6 @@ def interactive_flex_chart2(id=0,promember=0, y2 = y1 if xparam=='time': - xaxmax = x1.max() xaxmin = x1.min() xaxmax = get_datetimes([xaxmax],tzinfo=1)[0]