I have a dataframe in python
import pandas as pd
d = {'name':['a','b','c','d','e'],'location1': [1, 2,3,8,6], 'location2':
[2,1,4,6,8]}
df = pd.DataFrame(data=d)
df is as follow:
name location1 location2
0 a 1 2
1 b 2 1
2 c 3 4
3 d 8 6
4 e 6 8
I try to obtain a dataframe as:
name loc
0 a [1, 2]
1 b [2, 1]
2 c [3, 4]
3 d [8, 6]
4 e [6, 8]
How to efficiently convert that?