Reputation: 928
I have a data in a numpy array with multiple arrays inside of them, and I need to extract the average of each position array to plot a average plot of this data. What is the best way to do this?
Example of how the data is storage:
array([[ 0.00474308, 0.00513834, 0.00513834, ..., 0.00395257,
0.00355731, 0.00316206],
[ 0.00474308, 0.00474308, 0.00513834, ..., 0.00395257,
0.00355731, 0.00316206],
[ 0.00474308, 0.00434783, 0.00513834, ..., 0.00395257,
0.00355731, 0.00316206],
...,
[ 0.00513834, 0.00513834, 0.0055336 , ..., 0.00316206,
0.00355731, 0.00316206],
[ 0.00474308, 0.00474308, 0.0055336 , ..., 0.00316206,
0.00355731, 0.00316206],
[ 0.00474308, 0.00474308, 0.00513834, ..., 0.00355731,
0.00355731, 0.00316206]])
The new array need to contain the following format:
array([ avg(arr1[0]+arr2[0]+...+arrN[0]), avg(arr1[1]+arr2[1]+...+arrN[1]),...,avg(arr1[N]+arr2[N]+...+arrN[N])])
The picture bellow illustrate all data plotted in a graph.
Upvotes: 0
Views: 2128
Reputation: 5580
Assuming the data are stored in a 2D array with the time axis along the first dimension and the graph index in the second dimension, something like:
arr.mean(axis=-1)
Upvotes: 3