title: calculate average of y values with different x values
body: <p>I tried to calculate the average of <code>y</code> from different arrays such as <code>np.mean(,axis=1)</code>, but with different <code>x</code> values.</p>
  
  <p>To produce <code>x</code> and <code>y</code> arrays, I used the code as below:</p>
  
  <pre><code>x1=np.arange(10)
  x2 = np.arange(10)+1  
  x3 = np.arange(10)+2
  x4 = np.arange(10)+3
  y1 = x1+1
  y2 = x2+2
  y3 = x3+3
  y4 = x4 +4
  </code></pre>
  
  <p>The code produces:</p>
  
  <pre><code>x1 = [0 1 2 3 4 5 6 7 8 9]
  x2 = [ 1  2  3  4  5  6  7  8  9 10]
  x3 = [ 2  3  4  5  6  7  8  9 10 11]
  x4 = [ 3  4  5  6  7  8  9 10 11 12]
  y1 = [ 1  2  3  4  5  6  7  8  9 10]
  y2 = [ 3  4  5  6  7  8  9 10 11 12]
  y3 = [ 5  6  7  8  9 10 11 12 13 14]
  y4 = [ 7  8  9 10 11 12 13 14 15 16]
  </code></pre>
  
  <p>If I plot (x1,y1), (x2,y2), (x3,y3), (x4,y4), y values are distributed from x values between 0 and 16 as below. Some x value have just one y values and other may have several values in the plot. I would like to take an average of y values at each x values.</p>
  
  <p><a href="https://i.stack.imgur.com/XrGUp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XrGUp.png" alt="enter image description here"></a></p>