title: Python: Centering Features in Numpy Array
body: <p>I’m trying to normalize some values in a numpy array with the following shape:</p>
  
  <pre><code>import numpy as np
  X = np.random.rand(100, 20, 3)
  </code></pre>
  
  <p>This data says there are 100 time stamps for each of 20 observations, where each observation has 3 dimensional attributes (x, y, z). I want to normalize the x, y, z dimensional attributes in the following way. For each dimension, I want to subtract the min then divide by the resulting max (to “center” the dimension’s values).</p>
  
  <p>I attempted to do this with the following:</p>
  
  <pre><code># center all features
  for i in range(3):
    X[:][:][i] -= np.min(X[:][:][i])
    X[:][:][i] /= np.max(X[:][:][i])
  </code></pre>
  
  <p>This does not mutate all values of the <code>ith</code> dimension, however.</p>
  
  <p>How can I center my features in this way? Any help others can offer would be greatly appreciated!</p>