Skip to content

Commit

Permalink
column rename fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanAugust committed Jul 15, 2023
1 parent 890fc04 commit eb6822d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cheetahpy/local_opendata.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class opendata_dataset(object):
def __init__(self, root_dir:str):
self.root_dir = root_dir
# self.athlete_ids = self.get_athlete_ids()
self.athlete_ids = self.get_athlete_ids()

def get_athlete_ids(self):
"""Preform a walk of the local dir for all available athlete IDs."""
Expand Down Expand Up @@ -89,7 +89,11 @@ def safe_split(val):
decompressed_df = pd.DataFrame(original_series.dropna().tolist(), index=slim_original_series.index)
# add column names at time of construction? would need to check size of the list in the series
if decompressed_df.shape[1] == 2:
decompressed_df.set_axis([f'{metric_base_name}_value',f'{metric_base_name}_duration'], axis=1)
new_cols = [f'{metric_base_name}_value',f'{metric_base_name}_duration']
# decompressed_df.set_axis(new_cols, axis='columns') ### bullshit, this doesn't work
decompressed_df.columns = new_cols
else:
decompressed_df.set_axis([f'{metric_base_name}_value_{x}' for x in range(decompressed_df.shape[1])], axis=1)
new_cols = [f'{metric_base_name}_value_{x}' for x in range(decompressed_df.shape[1])]
# decompressed_df.set_axis(new_cols, axis='columns') ### bullshit, this doesn't work
decompressed_df.columns = new_cols
return decompressed_df
15 changes: 15 additions & 0 deletions tests/test_opendata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# import pytest

from cheetahpy import opendata_dataset


def test_opendata_load():
# od = opendata_dataset(root_dir='./tests/open_data/')
# print(od.get_athlete_ids())
# od.get_athlete_summary(od.get_athlete_ids()[0])
assert 1==1

if __name__ == '__main__':
test_opendata_load()

print("Everything passed")

0 comments on commit eb6822d

Please sign in to comment.