Private
Public Access
1
0

small play with the algo

This commit is contained in:
Sander Roosendaal
2021-01-06 08:34:44 +01:00
parent 0cec60d063
commit d850ec4305

View File

@@ -106,7 +106,7 @@ from pandas.core.groupby.groupby import DataError
def newtestpower(x): def newtestpower(x):
try: try:
if abs(x['testpower'] - x['testdup']) < 0.2: if abs(x['testpower'] - x['testdup']) <= 0.2:
return np.nan return np.nan
except (AttributeError,TypeError): except (AttributeError,TypeError):
return np.nan return np.nan
@@ -198,18 +198,19 @@ def build_goldmedalstandards(workouts,kfitness):
# fitnesses.append(np.nan) # fitnesses.append(np.nan)
for w in workouts: for w in workouts:
ids = [w.id for w in workouts.filter(date__gte=w.date-datetime.timedelta(days=42), ids = [ww.id for ww in workouts.filter(date__gte=w.date-datetime.timedelta(days=42),
date__lte=w.date)] date__lte=w.date)]
powerdf = df[df['workout'].isin(ids)] powerdf = df[df['workout'].isin(ids)]
indexmax = powerdf['goldmedalstandard'].idxmax() indexmax = powerdf['goldmedalstandard'].idxmax()
theid = powerdf.loc[indexmax,'workout'] theid = powerdf.loc[indexmax,'workout']
powertest = powerdf['goldmedalstandard'].max() powertest = powerdf['goldmedalstandard'].max()
durationtest = powerdf.loc[indexmax,'goldmedalduration'] durationtest = powerdf.loc[indexmax,'goldmedalduration']
w2 = Workout.objects.get(id=theid)
dates.append(arrow.get(w.date).datetime) dates.append(arrow.get(w2.date).datetime)
if powertest > 0: if powertest > 0:
testpower.append(powertest) testpower.append(powertest)
testduration.append(durationtest) testduration.append(durationtest)