I have a data frame as below:
id points
0 1 (-2.3, 7)
1 1 (-5, 7)
2 1 (-6.9, 5)
3 2 (2, 5.9)
4 2 (-0.3, -8)
I am trying to use groupby id and get a numpy 2darray like below:
df2 = df.groupby(["id"])["points"]\
.apply(lambda x : np.array(x.values)).reset_index()
This works but it changes to list of tuples (like below), how to change to numpy array ? OR what I am considering as list of tuples is actually a numpy 2d array?
id points
0 1 [ (-2.3, 7), (-5,7), (-6.9,5) ]
1 2 [ (2, 5.9), (-0.3, -8) ]