What Is The Purpose Of The Replace Parameter For The Sample Function In Pandas?
I am asking about this feature: df.sample(frac=0.5, replace=True, random_state=1) available as an option upon sampling a DataFrame. On the pandas reference, it says it is to: Sam
Solution 1:
It means if input data are repeating or not.
Sample:
df = pd.DataFrame({'a': range(10)})
#here is duplicated value 5print (df.sample(frac=0.5, replace=True, random_state=1))
5588995500#all values are uniqueprint (df.sample(frac=0.5, replace=False, random_state=1))
a
2299664400
You can check related answer:
It controls whether the sample is returned to the sample pool. If you want only unique samples then this should be false.
Post a Comment for "What Is The Purpose Of The Replace Parameter For The Sample Function In Pandas?"