Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_patrols_from_id() function #42

Merged
merged 6 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion ecoscope/io/earthranger.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,31 @@ def get_patrols(self, since=None, until=None, patrol_type=None, status=None, **a
df = df.sort_values(by="serial_number").reset_index(drop=True)
return df

def get_patrol_segments_from_patrol_id(self, patrol_id, **addl_kwargs):
"""
Download patrols for a given `patrol id`.

Parameters
----------
patrol_id :
Patrol UUID.
kwargs
Additional parameters to pass to `_get`.

Returns
-------
dataframe : Dataframe of patrols.
"""

params = self._clean_kwargs(addl_kwargs)

object = f"activity/patrols/{patrol_id}/"
df = self._get(object, **params)
df["patrol_segments"][0].pop("updates")
df.pop("updates")

return pd.DataFrame(dict([(k, pd.Series(v)) for k, v in df.items()]))

def get_patrol_segments(self):
object = "activity/patrols/segments/"
return pd.DataFrame(
Expand All @@ -657,7 +682,7 @@ def get_observations_for_patrols(self, patrols_df, **kwargs):
Download observations for provided `patrols_df`.
Parameters
----------
patrols_df : pd.DataFrame
patrols_df :
Data returned from a call to `get_patrols`.
kwargs
Additional parameters to pass to `get_subject_observations`.
Expand Down
2 changes: 1 addition & 1 deletion ecoscope/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.3.5"
__version__ = "1.4.0"
Loading