From 7e78abc1ef4bef2874dc1dc8adcdb6ae14aeb872 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 22 Aug 2017 22:28:09 +0200 Subject: [PATCH] split seems to be working now --- rowers/dataprep.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/rowers/dataprep.py b/rowers/dataprep.py index b454942a..9dfb3e68 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -828,7 +828,34 @@ def split_workout(r,parent,splitsecond,splitmode): data1 = data[data['time']<=splitsecond].copy() data2 = data[data['time']>splitsecond].copy() + data1 = data1.sort_values(['time']) + data1 = data1.interpolate(method='linear',axis=0,limit_direction='both', + limit=10) + data1.fillna(method='bfill',inplace=True) + + # Some new stuff to try out + data1 = data1.groupby('time',axis=0).mean() + data1['time'] = data1.index + data1.reset_index(drop=True,inplace=True) + + data2 = data2.sort_values(['time']) + data2 = data2.interpolate(method='linear',axis=0,limit_direction='both', + limit=10) + data2.fillna(method='bfill',inplace=True) + + # Some new stuff to try out + data2 = data2.groupby('time',axis=0).mean() + data2['time'] = data2.index + data2.reset_index(drop=True,inplace=True) + + data1['pace'] = data1['pace']/1000. + data2['pace'] = data2['pace']/1000. + + + data1.drop_duplicates(subset='time',inplace=True) + data2.drop_duplicates(subset='time',inplace=True) + messages = [] ids = [] @@ -839,8 +866,9 @@ def split_workout(r,parent,splitsecond,splitmode): messages.append(message) ids.append(id) if 'keep second' in splitmode: - data2['cumdist'] = data2['cumdist'] - data2['cumdist'].min() - data2['time'] = data2['time'] - data2['time'].min() + data2['cumdist'] = data2['cumdist'] - data2.ix[0,'cumdist'] + data2['distance'] = data2['distance'] - data2.ix[0,'distance'] + data2['time'] = data2['time'] - data2.ix[0,'time'] id,message = new_workout_from_df(r,data2, title=parent.name+' Second Part', parent=parent) @@ -893,6 +921,7 @@ def new_workout_from_df(r,df, starttimeunix = mktime(startdatetime.utctimetuple()) df[' ElapsedTime (sec)'] = df['TimeStamp (sec)'] + print df[' ElapsedTime (sec)'].values df['TimeStamp (sec)'] = df['TimeStamp (sec)']+starttimeunix row = rrdata(df=df)