title: Multiplying multi-dimensional array by 1d array, to find nth product
body: <p>I have a large 2d array list of matrices, for example
  <code>matrices = np.random.rand(15, 10, 10)</code></p>
  <p>Each of the 15 matrices have 10X10 states (A-J).Each of the matrices are in order and represent time in years in increments of 1. Starting from <code>matrices[0]</code> which contains the matrix values for year 1, up to <code>matrices[14]</code> year 15.</p>
  <p>The table below shows my an example of my customer data, I have 12000 customers.</p>
  <pre><code>customer| current_state | year  | amount
  ax111   |   A           |   3   |  300
  ax112   |   D           |   4   |  4890
  ax113   |   G           |   9   |  624
  </code></pre>
  <p>I basically need to match each customers year to the correct matrix and place their amount in their current_state creating a vector for each customer.
  Example:</p>
  <p><code>ax111 = np.array([300,0,0,0,0,0,0,0,0,0])</code> (amount 300 placed at state A, 1st element)</p>
  <p><code>ax112 = np([0,0,0,4890,0,0,0,0,0,0])</code> (amount 4890 placed at state D, 4th element)</p>
  <p>I then need to multiply each customers array by the 2d array list <code>matrices</code>, based on the customers year, and continue multiplying the product by the next matrix until year 15, <code>matrices[14]</code> is reached for each customer.</p>
  <p>The code below works for 1 customer, how can I run it for all 12000 customers.</p>
  <pre><code>matrices = np.random.rand(15, 10, 10)
  ax111 = np.array([300,0,0,0,0,0,0,0,0,0])
  output = ax111
  results = []
  for arr in matrices[3:14]:
      output = output@arr
      results.append(output)
  </code></pre>
  <p>The output for the code above will be a (15,10,10) array list. How can I efficiently apply this to 12000 customers?</p>