jeudi 20 juillet 2017

What exactly does the Pandas random_state do?

I have the following code where I use the Pandas random_state

randomState = 123
sampleSize = 750
df = pd.read_csv(filePath, delim_whitespace=True)
df_s = df.sample(n=sampleSize, random_state=randomState)

This generates a sample dataframe df_s. Every time I run the code with the same randomState, I get the same sample df_s. When I change the value from 123 to 12 the sample changes as well, so I guess that's what the random_state does.

My silly question: How do the number change affect the sample change? I read the Pandas documentation and the Numpy documentation, but could not get a clear picture.

Any straight forward explanation with an example will be much appreciated.




Aucun commentaire:

Enregistrer un commentaire