diff --git a/code/behavior.py b/code/behavior.py index b89a28a..dd32ef2 100644 --- a/code/behavior.py +++ b/code/behavior.py @@ -1,11 +1,41 @@ from pathlib import Path + +import numpy as np +from IPython import embed from pandas import read_csv + + class Behavior: + """Load behavior data from csv file as class attributes + Attributes + ---------- + behavior_type: + behavioral_category: + comment_start: + comment_stop: + dataframe: pandas dataframe with all the data + duration_s: + media_file: + observation_date: + observation_id: + start_s: + stop_s: + total_length: + """ + def __init__(self, datapath: str) -> None: csv_file = str(sorted(Path(datapath).glob('**/*.csv'))[0]) self.dataframe = read_csv(csv_file, delimiter=',') + for key in self.dataframe: + if ' ' in key: + new_key = key.replace(' ', '_') + if '(' in new_key: + new_key = new_key.replace('(', '') + new_key = new_key.replace(')', '') + new_key = new_key.lower() + setattr(self, new_key, np.array(self.dataframe[key])) def main(datapath: str):