@@ -3951,7 +3951,9 @@ def tail(self, n=5):
3951
3951
def sample (self , n = None , frac = None , replace = False , weights = None ,
3952
3952
random_state = None , axis = None ):
3953
3953
"""
3954
- Returns a random sample of items from an axis of object.
3954
+ Return a random sample of items from an axis of object.
3955
+
3956
+ You can use `random_state` for reproducibility.
3955
3957
3956
3958
Parameters
3957
3959
----------
@@ -3988,7 +3990,6 @@ def sample(self, n=None, frac=None, replace=False, weights=None,
3988
3990
3989
3991
Examples
3990
3992
--------
3991
-
3992
3993
Generate an example ``Series`` and ``DataFrame``:
3993
3994
3994
3995
>>> s = pd.Series(np.random.randn(50))
@@ -4027,6 +4028,16 @@ def sample(self, n=None, frac=None, replace=False, weights=None,
4027
4028
40 0.823173 -0.078816 1.009536 1.015108
4028
4029
15 1.421154 -0.055301 -1.922594 -0.019696
4029
4030
6 -0.148339 0.832938 1.787600 -1.383767
4031
+
4032
+ You can use `random state` for reproducibility:
4033
+
4034
+ >>> df.sample(random_state=1)
4035
+ A B C D
4036
+ 37 -2.027662 0.103611 0.237496 -0.165867
4037
+ 43 -0.259323 -0.583426 1.516140 -0.479118
4038
+ 12 -1.686325 -0.579510 0.985195 -0.460286
4039
+ 8 1.167946 0.429082 1.215742 -1.636041
4040
+ 9 1.197475 -0.864188 1.554031 -1.505264
4030
4041
"""
4031
4042
4032
4043
if axis is None :
0 commit comments