Skip to content

Instantly share code, notes, and snippets.

@gubser
Created January 30, 2019 10:03
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 gubser/03e7d085cbce5c027ee2289d7467ff5d to your computer and use it in GitHub Desktop.
Save gubser/03e7d085cbce5c027ee2289d7467ff5d to your computer and use it in GitHub Desktop.
This python snippet parses the `vector` column as a list of integers delimited by space and adds it as a new column
"""
| frame | which | center-x | center-y | vector | vector_array |
| 44 | 0 | 55.5 | 29.3 | "49 44 31 22 26 22 44 ..." | [49, 44, 31, 22, 26, 22, 44, ...] |
"""
import pandas as pd
df = pd.read_csv(r"C:\Users\egubser\Downloads\blobs.csv", sep=';')
df['vector_array'] = df.vector.apply(lambda v: [int(k) for k in v.split(' ')])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment