Skip to content

Commit

Permalink
attach_attributes function allows input a list of string
Browse files Browse the repository at this point in the history
  • Loading branch information
rongxiangsu committed Aug 21, 2023
1 parent 2b0e633 commit eeaa3ae
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
18 changes: 9 additions & 9 deletions examples/example_turkey_vultures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 25,
"id": "f41300e2",
"metadata": {
"is_executing": true
Expand All @@ -26,7 +26,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 26,
"id": "ae813970",
"metadata": {},
"outputs": [
Expand All @@ -48,7 +48,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 27,
"id": "4e4734c6",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -178,7 +178,7 @@
"4 1.0 11.101806 "
]
},
"execution_count": 3,
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -208,7 +208,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 28,
"id": "43ec53ce",
"metadata": {
"scrolled": true
Expand All @@ -218,8 +218,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 195 ms, sys: 39.5 ms, total: 234 ms\n",
"Wall time: 496 ms\n"
"CPU times: user 224 ms, sys: 17.6 ms, total: 242 ms\n",
"Wall time: 249 ms\n"
]
}
],
Expand All @@ -243,7 +243,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 29,
"id": "d651b2ed",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -373,7 +373,7 @@
"4 1.0 11.101806 "
]
},
"execution_count": 5,
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
12 changes: 10 additions & 2 deletions ortega/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,13 @@ def compute_interaction_duration(self):
self.df_interaction_events['duration'] = self.df_interaction_events['duration'].dt.total_seconds().div(60)
print(datetime.now(), f'Computing interaction duration complete!')

def attach_attributes(self, col: str, method: str):
self.df_all_intersection_pairs = extract_attributes(self.df_all_intersection_pairs, col, method)
def attach_attributes(self, col, method: str):
if method not in ['mean', 'difference']:
raise ValueError("Parameter 'method' must be one of these: ['mean','difference']!")
if isinstance(col, str):
self.df_all_intersection_pairs = extract_attributes(self.df_all_intersection_pairs, col, method)
elif isinstance(col, list):
for c in col:
self.df_all_intersection_pairs = extract_attributes(self.df_all_intersection_pairs, c, method)
else:
raise TypeError("Parameter 'col' must be either a string or a list of strings!")
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if __name__ == "__main__":
setup(
name='ortega',
version='1.0.12',
version='1.0.13',
author='MOVE lab@UCSB',
author_email="rongxiangsu@ucsb.edu",
packages=["ortega"],
Expand Down

0 comments on commit eeaa3ae

Please sign in to comment.