I am trying to change the labels of records by randomly selecing some of them. But the **random.sample()** function gives the error - "*TypeError: can't multiply sequence by non-int of type 'numpy.float64'*". How can I fix the error?

n = round(np.sum(Y) * fraction)

pos_of_1 = list(np.where(Y == 1)[0])

random_indices = random.sample(pos_of_1, n)Y[random_indices] = 0