So guys i have the following data:
import pandas as pd
a = [[0, 4, 'a', 1], [0, 4, 'b', 1], [0, 2, 'a', 0.5], [0, 2, 'b', -1], [0, 2, 'c', 1]]
df = pd.DataFrame(a)
df.columns = ['x', 'y', 'features', 'values']
x y features values
0 0 4 a 1.0
1 0 4 b 1.0
2 0 2 a 0.5
3 0 2 b -1.0
4 0 2 c 1.0
I want a new dataframe that looks like this:
b = [[0, 4, 1, 1, 0], [0, 2, 0.5, -1, 1]]
df2 = pd.DataFrame(b)
df2.columns = ['x', 'y', 'a', 'b', 'c']
x y a b c
0 0 4 1.0 1 0
1 0 2 0.5 -1 1
So I have to groupby(['x','y']) but then how I can continue? I want that the values in feature columns become new columns, ant then I use the values in 'values' col to fill these columns. please help me.