0

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.

This picture illustrate all data plotted in a graph

2
  • 2
    I answered your question but you didn't leave enough of a code example for me to be sure that the answer will work for you. In general it's best to ask questions that include a runnable code snippet, that way it's unambiguous that asker and answerer are talking about the same code. Commented Jun 13, 2017 at 19:51
  • @nathan12343, please check the edited post, where I put some piece of data and a best explanation of my case Commented Jun 13, 2017 at 20:09

1 Answer 1

3

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.