This is a simple operation I am having trouble accomplishing with numpy:
I have two numpy arrays:
import numpy as np
arr1 = np.array([12, 13, 14, 15])
arr2 = np.array([100, 200, 300, 400])
I would like four distinct numpy arrays:
a1 = np.array([12, 13, 14, 15, 100])
a2 = np.array([12, 13, 14, 15, 200])
a3 = np.array([12, 13, 14, 15, 300])
a4 = np.array([12, 13, 14, 15, 400])
What's the most "numpythonic" way to accomplish this?
I could repeat the first array using numpy.tile
, e.g.
repeats = np.tile(arr1, len(arr2))
But that's not optimal.