Im a doing an experiment several times (monte carlo simulation
). In the experiment I select a random number of columns and do the calculations with the selected columns. Initially I have to the experiment with 5 columns, and repeat it 100
times. My dataframe has 4000
columns.
I summarized the code, and I am only showing the part of the code which select randomly the columns. Please take into account that I repeat this procedure 100 times. The part of the code is as follows:
import numpy as np
import pandas as pd
df = pd.DataFrame(np.random.choice([0.0, 0.05], size=(1000,1000)))
rand_cols = np.random.permutation(df.columns)[0:5]
df2 = df[rand_cols].copy()
My question is the following:
Does the function np.random.permutation work with replacement or without replacement?
The reason I ask this question it is because I run the code several times, at the moment it is 100 times. I will probably run the code more time and I need to know if the function works with replacement. If the function does not work with replacement, is there another function that does the same and work with replacement?
Thanks