@@ -3718,7 +3718,9 @@ def tail(self, n=5):
3718
3718
def sample (self , n = None , frac = None , replace = False , weights = None ,
3719
3719
random_state = None , axis = None ):
3720
3720
"""
3721
- Returns a random sample of items from an axis of object.
3721
+ Return a random sample of items from an axis of object.
3722
+
3723
+ You can use `random state` for reproducibility
3722
3724
3723
3725
Parameters
3724
3726
----------
@@ -3753,9 +3755,15 @@ def sample(self, n=None, frac=None, replace=False, weights=None,
3753
3755
-------
3754
3756
A new object of same type as caller.
3755
3757
3756
- Examples
3758
+ See Also
3757
3759
--------
3760
+ Series.sample : Returns a random sample of items
3761
+ from an axis of object.
3762
+ DataFrame.sample : Returns a random sample of items
3763
+ from an axis of object.
3758
3764
3765
+ Examples
3766
+ --------
3759
3767
Generate an example ``Series`` and ``DataFrame``:
3760
3768
3761
3769
>>> s = pd.Series(np.random.randn(50))
@@ -3794,6 +3802,16 @@ def sample(self, n=None, frac=None, replace=False, weights=None,
3794
3802
40 0.823173 -0.078816 1.009536 1.015108
3795
3803
15 1.421154 -0.055301 -1.922594 -0.019696
3796
3804
6 -0.148339 0.832938 1.787600 -1.383767
3805
+
3806
+ You can use `random state` for reproducibility:
3807
+
3808
+ >>> df.sample(random_state=1)
3809
+ A B C D
3810
+ 37 -2.027662 0.103611 0.237496 -0.165867
3811
+ 43 -0.259323 -0.583426 1.516140 -0.479118
3812
+ 12 -1.686325 -0.579510 0.985195 -0.460286
3813
+ 8 1.167946 0.429082 1.215742 -1.636041
3814
+ 9 1.197475 -0.864188 1.554031 -1.505264
3797
3815
"""
3798
3816
3799
3817
if axis is None :
0 commit comments