Creating a Column of Random Numbers in a DataFrame
Python
1| import numpy as np 2| 3| # creates a column of random decimal numbers between 0 and 1 4| df['random'] = np.random.rand(len(df),1) 5| 6| # creates a column of random integers between 10 and 30 7| df['random_integer'] = np.random.randint(low=10, high=30, size=len(df))
105
92