Skip to content

Commit

Permalink
fix athlete summary bug
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanAugust committed Sep 23, 2023
1 parent eb6822d commit b5a771f
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions cheetahpy/local_opendata.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@ def get_athlete_summary(self, athlete_id:str, make_float:bool = True):
rides = json.loads(summary_json)['RIDES']
df = pd.json_normalize(rides)
if make_float:
for col in df.columns.tolist():
if 'METRIC' in col:
if isinstance(df[col].dropna().values[0], str):
df[col] = self._safe_convert(original_series=df[col], type_convert=float)
elif isinstance(df[col].dropna().values[0], list):
try:
decompression = self._safe_list_decompression(original_series=df[col], type_convert=float)
df = df.join(decompression)
del df[col]
except Exception as err:
print(f'{err}: {col}--fail')
else:
None
metric_cols = []
[metric_cols.append(col) if 'METRIC' in col else None for col in df.columns.tolist()]
for col in metric_cols:
if isinstance(df[col].dropna().values[0], str):
df[col] = self._safe_convert(original_series=df[col], type_convert=float)
elif isinstance(df[col].dropna().values[0], list):
try:
decompression = self._safe_list_decompression(original_series=df[col], type_convert=float)
df = df.join(decompression)
del df[col]
except Exception as err:
print(f'{err}: {col}--fail')
else:
None
return df

def get_athlete_activity_files(self, athlete_id:str) -> list:
Expand Down

0 comments on commit b5a771f

Please sign in to comment.