Reputation: 479
I have dataframes containing list cells:
a=pd.DataFrame([[[1,0,1],[0,1,0]],[[0,0,1],[0,1,0]],[[0,0,1],[0,1,0]]])
b=pd.DataFrame([[[0,0,1],[0,1,0]],[[0,0,1],[0,1,0]],[[0,0,1],[0,1,0]]])
c=pd.DataFrame([[[1,0,1],[0,0,0]],[[1,0,0],[0,1,0]],[[1,0,1],[0,0,0]]])
How do I add them position wise? e.g [1,0,1] + [0,0,1 ] = [1,0,2]
All I have done so far will sum the list to one number.
Upvotes: 0
Views: 28
Reputation: 323226
Change it to numpy
array
out = a.applymap(np.array) + b.applymap(np.array)
Out[135]:
0 1
0 [1, 0, 2] [0, 2, 0]
1 [0, 0, 2] [0, 2, 0]
2 [0, 0, 2] [0, 2, 0]
Upvotes: 2