I have several Panda's Dataframes that I would like to merge together. When I merge them I would like the values that have the same columns to become an array of values.
For example, I would like to merge two data frames together if they have the same value in a specified column. When they are merged the data becomes an array of values.
df1 =
A Value
0 x 0
1 y 0
df2 =
A Value
0 x 1
1 y 1
2 z 1
After Combining:
df =
A Number_Value
0 x [0, 1]
1 y [0, 1]
2 z [, 1]
I do not believe the merge() or concat() call would be appropriate. I thought calling .to_numpy() would be able to do this, if I were to convert each value in each row to an array, but that does not seem to work.