I have a pandas data frame with 50k rows. I'm trying to add a new column that is a randomly generated number from 1 to 5.
If I want 50k random numbers I'd use:
df1['randNumCol'] = random.sample(xrange(50000), len(df1))
but for this I'm not sure how to do it.
Side note in R, I'd do:
sample(1:5, 50000, replace = TRUE)
Any suggestions?
Aucun commentaire:
Enregistrer un commentaire