Edit: As @DanielF pointed out the approach I describe here is not best practice. I'll leave it here for reference, but see @DanielF's asnwer for a more optimal solution.
Another appoach is to get the "x, y coordinates" of the spikes and set those to 1.
With x refering to the row (i.e. 0 or 1) and y referring to the index.
Here's how you could implement this:
import numpy as np
spike_train = np.zeros((2,2000)) # Array to be filled
n_spikes_per_row = 100
x = np.repeat([0,1], n_spikes_per_row)
y = np.random.randint(low=0, high = spike_train.shape[1]-1, size = 2 * n_spikes_per_row) # Indexes to fill
spike_train[x, y] = 1
Maybe a bit redundant to tell, but x and y are flat arrays holding the randomly selected coordinates like so:
x = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
y = [13, 5, 7, 4, 9, 14, 1, 1, 17, 4]
As a final comment: since you're selecting random integers you might get the same value in y multiple times, this leads to fewer 'spikes' in the final array. Maybe you already knew or it does not matter fot your implementation but I wanted to have mentioned it just in case. Good luck!