Last active
December 2, 2019 12:37
-
-
Save lasagnaphil/95aa9cc93addd0bff25dc280fe33551e to your computer and use it in GitHub Desktop.
Extract categories from CMU
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()} |
Author
lasagnaphil
commented
Dec 2, 2019
- Install pandas
- Get CMU Excel file and convert it into csv (using tab delimiter: \t)
- Use this ocde
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment