Private
Public Access
1
0

removing obsolete .ix calls to pandas

This commit is contained in:
Sander Roosendaal
2019-02-09 08:52:52 +01:00
parent a5d8dbdf07
commit b88c6e902a
13 changed files with 93 additions and 85 deletions

View File

@@ -327,11 +327,11 @@ def createc2workoutdata_as_splits(w):
maxhr = int(df[' HRCur (bpm)'].max()) maxhr = int(df[' HRCur (bpm)'].max())
# adding diff, trying to see if this is valid # adding diff, trying to see if this is valid
t = 10*df.ix[:,' ElapsedTime (sec)'].diff().values t = 10*df.loc[:,' ElapsedTime (sec)'].diff().values
t[0] = t[1] t[0] = t[1]
d = df.ix[:,' Horizontal (meters)'].diff().values d = df.loc[:,' Horizontal (meters)'].diff().values
d[0] = d[1] d[0] = d[1]
p = 10*df.ix[:,' Stroke500mPace (sec/500m)'].values p = 10*df.loc[:,' Stroke500mPace (sec/500m)'].values
t = t.astype(int) t = t.astype(int)
d = d.astype(int) d = d.astype(int)
p = p.astype(int) p = p.astype(int)
@@ -396,11 +396,11 @@ def createc2workoutdata(w):
maxhr = 0 maxhr = 0
# adding diff, trying to see if this is valid # adding diff, trying to see if this is valid
t = 10*row.df.ix[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)'] t = 10*row.df.loc[:,'TimeStamp (sec)'].values-10*row.df.loc[:,'TimeStamp (sec)'].iloc[0]
t[0] = t[1] t[0] = t[1]
d = 10*row.df.ix[:,' Horizontal (meters)'].values d = 10*row.df.loc[:,' Horizontal (meters)'].values
d[0] = d[1] d[0] = d[1]
p = abs(10*row.df.ix[:,' Stroke500mPace (sec/500m)'].values) p = abs(10*row.df.loc[:,' Stroke500mPace (sec/500m)'].values)
p = np.clip(p,0,3600) p = np.clip(p,0,3600)
if w.workouttype == 'bike': if w.workouttype == 'bike':
p = 2.0*p p = 2.0*p
@@ -817,35 +817,35 @@ def add_workout_from_data(user,importid,data,strokedata,
unixtime = cum_time+starttimeunix unixtime = cum_time+starttimeunix
# unixtime[0] = starttimeunix # unixtime[0] = starttimeunix
seconds = 0.1*strokedata.ix[:,'t'] seconds = 0.1*strokedata.loc[:,'t']
nr_rows = len(unixtime) nr_rows = len(unixtime)
try: try:
latcoord = strokedata.ix[:,'lat'] latcoord = strokedata.loc[:,'lat']
loncoord = strokedata.ix[:,'lon'] loncoord = strokedata.loc[:,'lon']
except: except:
latcoord = np.zeros(nr_rows) latcoord = np.zeros(nr_rows)
loncoord = np.zeros(nr_rows) loncoord = np.zeros(nr_rows)
try: try:
strokelength = strokedata.ix[:,'strokelength'] strokelength = strokedata.loc[:,'strokelength']
except: except:
strokelength = np.zeros(nr_rows) strokelength = np.zeros(nr_rows)
dist2 = 0.1*strokedata.ix[:,'d'] dist2 = 0.1*strokedata.loc[:,'d']
try: try:
spm = strokedata.ix[:,'spm'] spm = strokedata.loc[:,'spm']
except KeyError: except KeyError:
spm = 0*dist2 spm = 0*dist2
try: try:
hr = strokedata.ix[:,'hr'] hr = strokedata.loc[:,'hr']
except KeyError: except KeyError:
hr = 0*spm hr = 0*spm
pace = strokedata.ix[:,'p']/10. pace = strokedata.loc[:,'p']/10.
pace = np.clip(pace,0,1e4) pace = np.clip(pace,0,1e4)
pace = pace.replace(0,300) pace = pace.replace(0,300)

View File

@@ -56,6 +56,19 @@ timezones = (
(x,x) for x in pytz.common_timezones (x,x) for x in pytz.common_timezones
) )
def half_year_from_now():
return (datetime.datetime.now(tz=timezone.utc)+timezone.timedelta(days=182)).date()
def a_week_from_now():
return (datetime.datetime.now(tz=timezone.utc)+timezone.timedelta(days=7)).date()
def current_day():
return (datetime.datetime.now(tz=timezone.utc)).date()
def current_time():
return datetime.datetime.now(tz=timezone.utc)
class UserFullnameChoiceField(forms.ModelChoiceField): class UserFullnameChoiceField(forms.ModelChoiceField):
def label_from_instance(self,obj): def label_from_instance(self,obj):
return obj.get_full_name() return obj.get_full_name()
@@ -246,7 +259,7 @@ class PowerTimeFitnessMetric(models.Model):
('water','On the water') ('water','On the water')
) )
date = models.DateField(default=datetime.date.today) date = models.DateField(default=current_day)
last_workout = models.IntegerField(default=0) last_workout = models.IntegerField(default=0)
user = models.ForeignKey(User) user = models.ForeignKey(User)
PowerFourMin = models.FloatField(default=0) PowerFourMin = models.FloatField(default=0)
@@ -334,7 +347,7 @@ class TeamForm(ModelForm):
class TeamInvite(models.Model): class TeamInvite(models.Model):
team = models.ForeignKey(Team) team = models.ForeignKey(Team)
user = models.ForeignKey(User,null=True) user = models.ForeignKey(User,null=True)
issuedate = models.DateField(default=datetime.date.today) issuedate = models.DateField(default=current_day)
code = models.CharField(max_length=150,unique=True) code = models.CharField(max_length=150,unique=True)
email = models.CharField(max_length=150,null=True,blank=True) email = models.CharField(max_length=150,null=True,blank=True)
@@ -352,7 +365,7 @@ class TeamInviteForm(ModelForm):
class TeamRequest(models.Model): class TeamRequest(models.Model):
team = models.ForeignKey(Team) team = models.ForeignKey(Team)
user = models.ForeignKey(User,null=True) user = models.ForeignKey(User,null=True)
issuedate = models.DateField(default=datetime.date.today) issuedate = models.DateField(default=current_day)
code = models.CharField(max_length=150,unique=True) code = models.CharField(max_length=150,unique=True)
from utils import ( from utils import (
@@ -655,8 +668,8 @@ class Rower(models.Model):
paidplan = models.ForeignKey(PaidPlan,null=True,default=None) paidplan = models.ForeignKey(PaidPlan,null=True,default=None)
planexpires = models.DateField(default=datetime.date.today) planexpires = models.DateField(default=current_day)
teamplanexpires = models.DateField(default=datetime.date.today) teamplanexpires = models.DateField(default=current_day)
clubsize = models.IntegerField(default=0) clubsize = models.IntegerField(default=0)
protrialexpires = models.DateField(blank=True,null=True) protrialexpires = models.DateField(blank=True,null=True)
plantrialexpires = models.DateField(blank=True,null=True) plantrialexpires = models.DateField(blank=True,null=True)
@@ -1021,11 +1034,6 @@ class GeoPoint(models.Model):
# of multiple GeoPoint instances # of multiple GeoPoint instances
def half_year_from_now():
return (timezone.now()+timezone.timedelta(days=182)).date()
def a_week_from_now():
return (timezone.now()+timezone.timedelta(days=7)).date()
# models related to training planning - draft # models related to training planning - draft
# Do we need a separate class TestTarget? # Do we need a separate class TestTarget?
@@ -1104,7 +1112,7 @@ class TrainingPlan(models.Model):
name = models.CharField(max_length=150,blank=True) name = models.CharField(max_length=150,blank=True)
status = models.BooleanField(default=True,verbose_name='Active') status = models.BooleanField(default=True,verbose_name='Active')
target = models.ForeignKey(TrainingTarget,blank=True,null=True) target = models.ForeignKey(TrainingTarget,blank=True,null=True)
startdate = models.DateField(default=datetime.date.today) startdate = models.DateField(default=current_day)
enddate = models.DateField( enddate = models.DateField(
default=half_year_from_now) default=half_year_from_now)
@@ -1193,7 +1201,7 @@ class TrainingPlanForm(ModelForm):
elif self.instance.pk is not None: elif self.instance.pk is not None:
self.fields['target'].queryset = TrainingTarget.objects.filter( self.fields['target'].queryset = TrainingTarget.objects.filter(
manager=self.instance.manager, manager=self.instance.manager,
date__gte=datetime.date.today()).order_by("date") date__gte=current_day()).order_by("date")
else: else:
self.fields.pop('target') self.fields.pop('target')
@@ -1468,7 +1476,7 @@ def macrocyclecheckdates(plan):
class TrainingMacroCycle(models.Model): class TrainingMacroCycle(models.Model):
plan = models.ForeignKey(TrainingPlan) plan = models.ForeignKey(TrainingPlan)
name = models.CharField(max_length=150,blank=True) name = models.CharField(max_length=150,blank=True)
startdate = models.DateField(default=datetime.date.today) startdate = models.DateField(default=current_day)
enddate = models.DateField( enddate = models.DateField(
default=half_year_from_now) default=half_year_from_now)
notes = models.TextField(max_length=300,blank=True) notes = models.TextField(max_length=300,blank=True)
@@ -1554,7 +1562,7 @@ class TrainingMacroCycleForm(ModelForm):
class TrainingMesoCycle(models.Model): class TrainingMesoCycle(models.Model):
plan = models.ForeignKey(TrainingMacroCycle) plan = models.ForeignKey(TrainingMacroCycle)
name = models.CharField(max_length=150,blank=True) name = models.CharField(max_length=150,blank=True)
startdate = models.DateField(default=datetime.date.today) startdate = models.DateField(default=current_day)
enddate = models.DateField( enddate = models.DateField(
default=half_year_from_now) default=half_year_from_now)
notes = models.TextField(max_length=300,blank=True) notes = models.TextField(max_length=300,blank=True)
@@ -1629,7 +1637,7 @@ class TrainingMesoCycle(models.Model):
class TrainingMicroCycle(models.Model): class TrainingMicroCycle(models.Model):
plan = models.ForeignKey(TrainingMesoCycle) plan = models.ForeignKey(TrainingMesoCycle)
name = models.CharField(max_length=150,blank=True) name = models.CharField(max_length=150,blank=True)
startdate = models.DateField(default=datetime.date.today) startdate = models.DateField(default=current_day)
enddate = models.DateField( enddate = models.DateField(
default=half_year_from_now) default=half_year_from_now)
notes = models.TextField(max_length=300,blank=True) notes = models.TextField(max_length=300,blank=True)
@@ -1776,7 +1784,7 @@ class PlannedSession(models.Model):
comment = models.TextField(max_length=500,blank=True, comment = models.TextField(max_length=500,blank=True,
) )
startdate = models.DateField(default=datetime.date.today, startdate = models.DateField(default=current_day,
verbose_name='On or After') verbose_name='On or After')
enddate = models.DateField(default=a_week_from_now, enddate = models.DateField(default=a_week_from_now,
@@ -3288,10 +3296,10 @@ class RowerForm(ModelForm):
# An announcement that goes to the right of the workouts list # An announcement that goes to the right of the workouts list
# optionally sends a tweet to our twitter account # optionally sends a tweet to our twitter account
class SiteAnnouncement(models.Model): class SiteAnnouncement(models.Model):
created = models.DateField(default=datetime.date.today) created = models.DateField(default=current_day)
announcement = models.TextField(max_length=280) announcement = models.TextField(max_length=280)
expires = models.DateField(default=datetime.date.today) expires = models.DateField(default=current_day)
modified = models.DateField(default=datetime.date.today) modified = models.DateField(default=current_day)
dotweet = models.BooleanField(default=False) dotweet = models.BooleanField(default=False)
def save(self, *args, **kwargs): def save(self, *args, **kwargs):

View File

@@ -58,9 +58,9 @@ def y_axis_range(ydata,miny=0,padding=.1,ultimate=[-1e9,1e9]):
def mkplot(row,title): def mkplot(row,title):
df = row.df df = row.df
t = df.ix[:,' ElapsedTime (sec)'] t = df.loc[:,' ElapsedTime (sec)']
p = df.ix[:,' Stroke500mPace (sec/500m)'] p = df.loc[:,' Stroke500mPace (sec/500m)']
hr = df.ix[:,' HRCur (bpm)'] hr = df.loc[:,' HRCur (bpm)']
end_time = int(df.ix[df.shape[0]-1,'TimeStamp (sec)']) end_time = int(df.ix[df.shape[0]-1,'TimeStamp (sec)'])
fig, ax1 = plt.subplots(figsize=(5,4)) fig, ax1 = plt.subplots(figsize=(5,4))
@@ -69,7 +69,7 @@ def mkplot(row,title):
ax1.set_xlabel('Time (h:m)') ax1.set_xlabel('Time (h:m)')
ax1.set_ylabel('(sec/500)') ax1.set_ylabel('(sec/500)')
yrange = y_axis_range(df.ix[:,' Stroke500mPace (sec/500m)'], yrange = y_axis_range(df.loc[:,' Stroke500mPace (sec/500m)'],
ultimate = [85,190]) ultimate = [85,190])
plt.axis([0,end_time,yrange[1],yrange[0]]) plt.axis([0,end_time,yrange[1],yrange[0]])

View File

@@ -117,10 +117,10 @@ def createrunkeeperworkoutdata(w):
# adding diff, trying to see if this is valid # adding diff, trying to see if this is valid
#t = row.df.ix[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)'] #t = row.df.ix[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)']
t = row.df.ix[:,'TimeStamp (sec)'].values-row.df.ix[0,'TimeStamp (sec)'] t = row.df.loc[:,'TimeStamp (sec)'].values-row.df.loc[:,'TimeStamp (sec)'].iloc[0]
t[0] = t[1] t[0] = t[1]
d = row.df.ix[:,'cum_dist'].values d = row.df.loc[:,'cum_dist'].values
d[0] = d[1] d[0] = d[1]
t = t.astype(int) t = t.astype(int)
d = d.astype(int) d = d.astype(int)

View File

@@ -124,11 +124,11 @@ def createsporttracksworkoutdata(w):
duration += +1.0e-6*w.duration.microsecond duration += +1.0e-6*w.duration.microsecond
# adding diff, trying to see if this is valid # adding diff, trying to see if this is valid
#t = row.df.ix[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)'] #t = row.df.loc[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)']
t = row.df.ix[:,'TimeStamp (sec)'].values-row.df.ix[0,'TimeStamp (sec)'] t = row.df.loc[:,'TimeStamp (sec)'].values-row.df.loc[:,'TimeStamp (sec)'].iloc[0]
t[0] = t[1] t[0] = t[1]
d = row.df.ix[:,'cum_dist'].values d = row.df.loc[:,'cum_dist'].values
d[0] = d[1] d[0] = d[1]
t = t.astype(int) t = t.astype(int)
d = d.astype(int) d = d.astype(int)

View File

@@ -518,42 +518,42 @@ def add_workout_from_data(user,importid,data,strokedata,
lapidx = res[1] lapidx = res[1]
unixtime = cum_time+starttimeunix unixtime = cum_time+starttimeunix
seconds = 0.1*strokedata.ix[:,'t'] seconds = 0.1*strokedata.loc[:,'t']
nr_rows = len(unixtime) nr_rows = len(unixtime)
try: try:
latcoord = strokedata.ix[:,'lat'] latcoord = strokedata.loc[:,'lat']
loncoord = strokedata.ix[:,'lon'] loncoord = strokedata.loc[:,'lon']
except: except:
latcoord = np.zeros(nr_rows) latcoord = np.zeros(nr_rows)
loncoord = np.zeros(nr_rows) loncoord = np.zeros(nr_rows)
try: try:
strokelength = strokedata.ix[:,'strokelength'] strokelength = strokedata.loc[:,'strokelength']
except: except:
strokelength = np.zeros(nr_rows) strokelength = np.zeros(nr_rows)
dist2 = 0.1*strokedata.ix[:,'d'] dist2 = 0.1*strokedata.loc[:,'d']
try: try:
spm = strokedata.ix[:,'spm'] spm = strokedata.loc[:,'spm']
except KeyError: except KeyError:
spm = 0*dist2 spm = 0*dist2
try: try:
hr = strokedata.ix[:,'hr'] hr = strokedata.loc[:,'hr']
except KeyError: except KeyError:
hr = 0*spm hr = 0*spm
pace = strokedata.ix[:,'p']/10. pace = strokedata.loc[:,'p']/10.
pace = np.clip(pace,0,1e4) pace = np.clip(pace,0,1e4)
pace = pace.replace(0,300) pace = pace.replace(0,300)
velo = 500./pace velo = 500./pace
try: try:
power = strokedata.ix[:,'power'] power = strokedata.loc[:,'power']
except KeyError: except KeyError:
power = 2.8*velo**3 power = 2.8*velo**3

View File

@@ -31,7 +31,7 @@ class SimpleViewTest(TestCase):
except (IOError, WindowsError,OSError): except (IOError, WindowsError,OSError):
pass pass
def start_protrial(self): def test_start_protrial(self):
login = self.c.login(username=self.u.username, password=self.password) login = self.c.login(username=self.u.username, password=self.password)
self.assertTrue(login) self.assertTrue(login)
@@ -43,7 +43,7 @@ class SimpleViewTest(TestCase):
expected_url='/rowers/list-workouts/', expected_url='/rowers/list-workouts/',
status_code=302,target_status_code=200) status_code=302,target_status_code=200)
def start_plantrial(self): def test_start_plantrial(self):
login = self.c.login(username=self.u.username, password=self.password) login = self.c.login(username=self.u.username, password=self.password)
self.assertTrue(login) self.assertTrue(login)

View File

@@ -40,7 +40,7 @@ class OTWCPChartTest(TestCase):
row = rdata(a2) row = rdata(a2)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -124,16 +124,16 @@ class CPChartTest(TestCase):
recordsdf = pd.read_csv('rowers/tests/worldrecords.csv',encoding='utf-8') recordsdf = pd.read_csv('rowers/tests/worldrecords.csv',encoding='utf-8')
for i in range(len(recordsdf)): for i in recordsdf.index:
record = C2WorldClassAgePerformance( record = C2WorldClassAgePerformance(
name = recordsdf.ix[i,'name'], name = recordsdf.loc[i,'name'],
age = recordsdf.ix[i,'age'], age = recordsdf.loc[i,'age'],
distance = recordsdf.ix[i,'distance'], distance = recordsdf.loc[i,'distance'],
duration = recordsdf.ix[i,'duration'], duration = recordsdf.loc[i,'duration'],
power = recordsdf.ix[i,'power'], power = recordsdf.loc[i,'power'],
season = recordsdf.ix[i,'season'], season = recordsdf.loc[i,'season'],
sex = recordsdf.ix[i,'sex'], sex = recordsdf.loc[i,'sex'],
weightcategory = recordsdf.ix[i,'weightcategory'], weightcategory = recordsdf.loc[i,'weightcategory'],
) )
record.save() record.save()
@@ -142,11 +142,11 @@ class CPChartTest(TestCase):
r = self.u.rower r = self.u.rower
for i in range(len(perfsdf)): for i in perfsdf.index:
perf = CalcAgePerformance( perf = CalcAgePerformance(
age = age, age = age,
duration = perfsdf.ix[i,'duration'], duration = perfsdf.loc[i,'duration'],
power = perfsdf.ix[i,'power'], power = perfsdf.loc[i,'power'],
sex = r.sex, sex = r.sex,
weightcategory = r.weightcategory weightcategory = r.weightcategory
) )

View File

@@ -35,7 +35,7 @@ class C2Objects(DjangoTestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -169,7 +169,7 @@ class C2ObjectsTokenExpired(DjangoTestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -247,7 +247,7 @@ class StravaObjects(DjangoTestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -354,7 +354,7 @@ class STObjects(DjangoTestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -484,7 +484,7 @@ class RunKeeperObjects(DjangoTestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -577,7 +577,7 @@ class UAObjects(DjangoTestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -679,7 +679,7 @@ class TPObjects(DjangoTestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)

Binary file not shown.

View File

@@ -111,14 +111,14 @@ def createunderarmourworkoutdata(w):
notes = 'from '+w.workoutsource+' via rowsandall.com' notes = 'from '+w.workoutsource+' via rowsandall.com'
# adding diff, trying to see if this is valid # adding diff, trying to see if this is valid
#t = row.df.ix[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)'] #t = row.df.loc[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)']
t = row.df.ix[:,'TimeStamp (sec)'].values #-row.df.ix[0,'TimeStamp (sec)'] t = row.df.loc[:,'TimeStamp (sec)'].values #-row.df.ix[0,'TimeStamp (sec)']
# t += arrow.get(st).timestamp # t += arrow.get(st).timestamp
# t[0] = t[1] # t[0] = t[1]
d = row.df.ix[:,'cum_dist'].values d = row.df.loc[:,'cum_dist'].values
d[0] = d[1] d[0] = d[1]
t = t.astype(float) t = t.astype(float)

View File

@@ -405,8 +405,8 @@ def ewmovingaverage(interval,window_size):
idf_ewma1 = intervaldf.ewm(span=window_size) idf_ewma1 = intervaldf.ewm(span=window_size)
idf_ewma2 = intervaldf[::-1].ewm(span=window_size) idf_ewma2 = intervaldf[::-1].ewm(span=window_size)
i_ewma1 = idf_ewma1.mean().ix[:,'v'] i_ewma1 = idf_ewma1.mean().loc[:,'v']
i_ewma2 = idf_ewma2.mean().ix[:,'v'] i_ewma2 = idf_ewma2.mean().loc[:,'v']
interval2 = np.vstack((i_ewma1,i_ewma2[::-1])) interval2 = np.vstack((i_ewma1,i_ewma2[::-1]))
interval2 = np.mean( interval2, axis=0) # average interval2 = np.mean( interval2, axis=0) # average

View File

@@ -12,7 +12,7 @@ def start_trial_view(request):
r.protrialexpires = datetime.date.today()+datetime.timedelta(13) r.protrialexpires = datetime.date.today()+datetime.timedelta(13)
r.save() r.save()
url = reverse(workouts_view) url = reverse('workouts_view')
messages.info(request,'We have started your 14 day trial period') messages.info(request,'We have started your 14 day trial period')
@@ -40,7 +40,7 @@ def start_plantrial_view(request):
r.protrialexpires = datetime.date.today()+datetime.timedelta(13) r.protrialexpires = datetime.date.today()+datetime.timedelta(13)
r.save() r.save()
url = reverse(workouts_view) url = reverse('workouts_view')
messages.info(request,'We have started your 14 day trial period') messages.info(request,'We have started your 14 day trial period')
@@ -145,7 +145,7 @@ def rower_exportsettings_view(request,userid=0):
'name': 'Profile' 'name': 'Profile'
}, },
{ {
'url': reverse(rower_exportsettings_view), 'url': reverse('rower_exportsettings_view'),
'name': 'Export Settings' 'name': 'Export Settings'
} }
] ]
@@ -171,7 +171,7 @@ def rower_edit_view(request,rowerid=0,userid=0,message=""):
'name': 'Profile' 'name': 'Profile'
}, },
{ {
'url': reverse(rower_edit_view), 'url': reverse('rower_edit_view'),
'name': 'Account Settings' 'name': 'Account Settings'
} }
] ]
@@ -261,7 +261,7 @@ def rower_prefs_view(request,userid=0,message=""):
'name': 'Profile' 'name': 'Profile'
}, },
{ {
'url': reverse(rower_prefs_view), 'url': reverse('rower_prefs_view'),
'name': 'Zones' 'name': 'Zones'
} }
] ]
@@ -375,7 +375,7 @@ def rower_revokeapp_view(request,id=0):
form = RowerForm(instance=r) form = RowerForm(instance=r)
powerform = RowerPowerForm(instance=r) powerform = RowerPowerForm(instance=r)
grants = AccessToken.objects.filter(user=request.user) grants = AccessToken.objects.filter(user=request.user)
url = reverse(rower_edit_view) url = reverse('rower_edit_view')
return HttpResponseRedirect(url) return HttpResponseRedirect(url)
except AccessToken.DoesNotExist: except AccessToken.DoesNotExist:
raise Http404("Access token doesn't exist") raise Http404("Access token doesn't exist")
@@ -459,7 +459,7 @@ def rower_update_empower_view(
messages.info(request,successmessage) messages.info(request,successmessage)
url = reverse(workouts_view) url = reverse('workouts_view')
return HttpResponseRedirect(url) return HttpResponseRedirect(url)
else: else: