as the title says, I have this list called "list", containing multiple Dataframes (shape 120 x 120) with some numeric data, added from a previous list.
...
df_sum = list_dataframe[0]
for i in range (1, len(list_dataframe)):
df_sum = df_sum.add(list_dataframe[i])
list.append(df_sum)
Let's say that "list" contains 800 dataframes, so every index of this list contains a dataframe. I want to:
- create an array with the same length of "list"
- take every dataframe in "list", one by one, convert it into a Numpy array (120 x 120, so a matrix)
- add every Numpy array (120 x 120) into the array created (800).
So i want to obtain an array (with a length of 800, same of list), where every index contains one of the 800 Numpy array (matrix).
I have already used .to_numpy() function applied to the list with a for loop,
for i in range(len(list)):
list[i] = list[i].to_numpy()
but it generates a strange structure, like an array of array of array where the second one contains only one element, that is the dataframe converted into an array:
>>> list
>>>[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.]]),
array([[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
...,
How can I do that?