Suppose I have a dataframe like this (extracted from key/value SQL table):
id | key | value
------------------------
abc123 | foo | "horse"
abc123 | bar | 42
def456 | foo | "zebra"
def456 | foo | 101
I'd like to convert to a dataframe that pivots on the id
column, using the values of key
as new column names:
id | foo | bar
------------------------
abc123 | "horse | 42
def456 | "zebra" | 101
Is pivot what I'm looking for? Always had a hard time with my pivot intuition...
Any suggestions on how to do this idiomatic pandas way? Thanks.