Reputation: 583
I have a dataframe df like
X Y value
1 1 foo
1 2 bar
2 1 lo
2 2 la
is there an elegant way to transform it into a x-y-map like
1 2
1 foo bar
2 lo la
Upvotes: 2
Views: 802
Reputation: 13349
try:
df.set_index(['X', 'Y'])['value'].unstack()
Y 1 2
X
1 foo bar
2 lo la
Upvotes: 3