Skip to content

Instantly share code, notes, and snippets.

@rob-luke
Created June 25, 2020 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rob-luke/8576ad802f5b1481b94ebb5f5979cdb9 to your computer and use it in GitHub Desktop.
Save rob-luke/8576ad802f5b1481b94ebb5f5979cdb9 to your computer and use it in GitHub Desktop.
def summarise_triggers(raw):
import pandas as pd
df = pd.DataFrame()
for desc in np.unique(raw.annotations.description):
picks_desc = [d == desc for d in raw.annotations.description]
try:
# Handle triggers when they are still in numbers
desc = float(desc)
except:
# Handle triggers that have been converted to strings
desc = desc
df = df.append({'Trigger': desc,
'Occurances': np.sum(picks_desc)},
ignore_index=True)
return df.sort_values('Trigger')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment