Cohort


The tool takes a dataframe of compressed detections and a time parameter in minutes. It identifies groups of animals traveling together. Each station an animal visits is checked for other animals detected there within the specified time period.

The function returns a dataframe which you can use to help identify animal cohorts. The cohort is created from the compressed data that is a result from the compress_detections() function. Pass the compressed dataframe into the cohort() function along with a time interval in minutes (default is 60) to create the cohort dataframe.

Warning

Input files must include station, catalognumber,
seq_num, unqdetecid, and datecollected as columns.
from resonate.cohorts import cohort
from resonate.compress import compress_detections
import pandas as pd

time_interval = 60

data = pd.read_csv('/path/to/detections.csv')

compressed_df = compress_detections(data)

cohort_df = cohort(compressed_df, time_interval)

cohort_df

You can use the Pandas DataFrame.to_csv() function to output the file to a desired location.

# Saves the cohort file
cohort_df.to_csv('/path/to/output.csv', index=False)

Cohort Functions

cohorts.cohort(compressed_df, interval_time=60)

Creates a dataframe of cohorts using a compressed detection file

Parameters:
  • compressed_df – compressed dataframe
  • interval_time – cohort detection time interval (in minutes)
Returns:

cohort dataframe with the following columns

  • anml_1
  • anml_1_seq
  • station
  • anml_2
  • anml_2_seq
  • anml_2_arrive
  • anml_2_depart
  • anml_2_startunqdetecid
  • anml_2_endunqdetecid
  • anml_2_detcount