I have a dataframe
df = pd.DataFrame({
'Names': ['A', 'A', 'A', 'B', 'B', 'C', 'C', 'C'],
'Value': ['A1','A2','A3','B1','B2','C1','C2','C3']})
# Names Value
#0 A A1
#1 A A2
#2 A A3
#3 B B1
#4 B B2
#5 C C1
#6 C C2
#7 C C3
I wish to get it into the current state:
# Names Values
#0 A [A1, A2, A3]
#1 B [B1, B2]
#2 C [C1, C2, C3]
Are there any inbuilt functions in the pandas
or numpy
packages that can simplify this? Or am I forced to iterate it through using default python?