I was trying to make the following script but it gives me an error when executing it, if someone can help me, thank you very much.
I have a list Bxy of 666 elements inside I have a list of 95 elements as shown:
Bxy[0] es una lista [0,0,0,0,0,0,1,0,0,0,...,0] de 95 elementos
.
.
.
Bxy[665] es una lista [0,0,2,0,1,0,4,0,0,0,...,0] de 95 elementos
What I am trying to do is obtain a dataframe in which I obtain the sum of each list, forming a dataframe of 666 elements with the sum of the lists of 95 elements.
When transforming it to np.array I get the following:
np.array(Bxy)
array([[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]], dtype=object)
When I do the following it gives me an error.
df = pd.DataFrame()
df["Data"]= list (np.sum(np.array(Bxy), axis=1))
df
TypeError: unsupported operand type(s) for +: 'int' and 'list'
You should get a dataframe with 666 elements.
Data
0
2
0
5
0
1
..