Skip to content

Commit

Permalink
Merge pull request #1 from RyanAugust/athlete_fix
Browse files Browse the repository at this point in the history
fix athlete summary bug
  • Loading branch information
RyanAugust authored Sep 23, 2023
2 parents eb6822d + b5a771f commit de77fa9
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 de77fa9

Please sign in to comment.