Skip to content

Instantly share code, notes, and snippets.

@lasagnaphil
Last active December 2, 2019 12:37
Show Gist options
  • Save lasagnaphil/95aa9cc93addd0bff25dc280fe33551e to your computer and use it in GitHub Desktop.
Save lasagnaphil/95aa9cc93addd0bff25dc280fe33551e to your computer and use it in GitHub Desktop.
Extract categories from CMU
import pandas as pd
table = pd.read_csv('cmu-mocap-index-spreadsheet.csv', sep='\t')
table = table.dropna(axis=0)
table.columns = ['Motion', 'Description', 'Subject']
categories = [
'walk', 'run|jog', 'jump', 'dance', 'sit', 'climb', 'balance', 'hop', 'stretch', 'flip',
'basketball', 'soccer', 'boxing',
'drink', 'wash windows', 'bend', 'cartwheel',
'wave', 'limp',
]
temp_table = table.copy()
by_category = {}
for category in categories:
does_contain = temp_table['Description'].str.contains(category, case=True)
by_category[category] = temp_table[does_contain]
temp_table = temp_table[~does_contain]
result = {k: list(table['Motion']) for k, table in by_category.items()}
@lasagnaphil
Copy link
Author

  1. Install pandas
  2. Get CMU Excel file and convert it into csv (using tab delimiter: \t)
  3. Use this ocde

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment