Skip to content

Instantly share code, notes, and snippets.

@lockefox
Created August 19, 2017 17:39
Show Gist options
  • Save lockefox/e510f68e54c87b5c48a77f4fa79a7c20 to your computer and use it in GitHub Desktop.
Save lockefox/e510f68e54c87b5c48a77f4fa79a7c20 to your computer and use it in GitHub Desktop.
## Split out JSON-blob columns into their own tables ##
# Rotates out key/value pairs into their own columns
position_df = pd.DataFrame(list(kill_df['position']))
victim_df = pd.DataFrame(list(kill_df['victim']))
zkb_df = pd.DataFrame(list(kill_df['zkb']))
## Merge pivoted data back into source frame ##
# row-index has not changed, append-horizontally
combined_df = pd.concat([kill_df, position_df, victim_df, zkb_df], axis=1)
## Drop JSON-blob columns for sanity
combined_df = combined_df.drop(['position', 'victim', 'zkb'], 1)
killID killTime moonID solarSystemID x y z allianceID allianceName characterID characterName corporationID corporationName damageTaken factionID factionName shipTypeID fittedValue hash locationID npc points totalValue
64158479 2017-08-19 16:28:48 0 30000157 27668971838.564 -327762003.54411 66846273372.285 99000645 RvB - RED Federation 94315372 Canatana Jovakko 1699307293 Red Federation 1221 0 583 8162585.38 ef96d0c4a53b0a016e5eed28e91d52710de8ab61 40009948 False 23 8325314.02
64158462 2017-08-19 16:27:14 0 30001398 386153713869.05 -13468995620.414 -634133416093.47 0 96591218 Vyllden 1000045 Science and Trade Institute 5422 0 17476 25723822.37 d483cb8a79de89573c902ef45d4baeeac8cbcc14 50000196 False 1 26465753.63
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment