March 2020
Beginner to intermediate
352 pages
8h 40m
English
To generate random sampling with replacement, follow the given steps:
sack = np.array([4, 8, -2, 7, 5])sampler = np.random.randint(0, len(sack), size = 10)sampler
We created the sampler using the np.random.randint() method. The output of the preceding code is as follows:
array([3, 3, 0, 4, 0, 0, 1, 2, 1, 4])
draw = sack.take(sampler)draw
The output of the preceding code is as follows:
array([ 7, 7, 4, 5, 4, 4, 8, -2, 8, 5])
Compare the index of the sampler and then compare it with the original dataframe. The results are pretty obvious in this case. ...
Read now
Unlock full access