How do I subtract and divide a 2D array and a 1D array in Python Numpy?
<p>I have a 2D numpy array defined A, for example. I want to transform it into another 2D arrays according to the following statements:</p>

<pre><code>B = A - mean(A), the mean by the second axis
C = B / mean(A)
</code></pre>

<p>An example:</p>

<pre><code>&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; A = np.array([[1, 2, 3], [4, 6, 8]])
&gt;&gt;&gt; A
array([[1, 2, 3],
       [4, 6, 8]])
&gt;&gt;&gt; M = np.mean(A, axis=1)
&gt;&gt;&gt; M
array([ 2.,  6.])
&gt;&gt;&gt; B = ... # ???
&gt;&gt;&gt; B
array([[-1., 0., 1.],
       [-2., 0., 2.]])
&gt;&gt;&gt; C = ... # ???
&gt;&gt;&gt; C
array([[-0.5, 0., 0.5],
       [-0.33333333, 0., 0.33333333]])
</code></pre>