@@ -3525,46 +3525,45 @@ def filter(self, items=None, like=None, regex=None, axis=None):
35253525 Parameters
35263526 ----------
35273527 items : list-like
3528- List of info axis to restrict to (must not all be present)
3528+ List of info axis to restrict to (must not all be present).
35293529 like : string
3530- Keep info axis where "arg in col == True"
3530+ Keep info axis where "arg in col == True".
35313531 regex : string (regular expression)
3532- Keep info axis with re.search(regex, col) == True
3532+ Keep info axis with re.search(regex, col) == True.
35333533 axis : int or string axis name
35343534 The axis to filter on. By default this is the info axis,
3535- 'index' for Series, 'columns' for DataFrame
3535+ 'index' for Series, 'columns' for DataFrame.
35363536
35373537 Returns
35383538 -------
35393539 same type as input object
35403540
35413541 Examples
35423542 --------
3543- >>> df
3544- one two three
3545- mouse 1 2 3
3546- rabbit 4 5 6
3543+ >>> df = pd.DataFrame(np.array(([1,2,3],[4,5,6])),
3544+ ... index=['mouse', 'rabbit'],
3545+ ... columns=['one', 'two', 'three'])
35473546
35483547 >>> # select columns by name
35493548 >>> df.filter(items=['one', 'three'])
3550- one three
3549+ one three
35513550 mouse 1 3
35523551 rabbit 4 6
35533552
35543553 >>> # select columns by regular expression
35553554 >>> df.filter(regex='e$', axis=1)
3556- one three
3555+ one three
35573556 mouse 1 3
35583557 rabbit 4 6
35593558
35603559 >>> # select rows containing 'bbi'
35613560 >>> df.filter(like='bbi', axis=0)
3562- one two three
3561+ one two three
35633562 rabbit 4 5 6
35643563
35653564 See Also
35663565 --------
3567- pandas.DataFrame.loc
3566+ pandas.DataFrame.loc : Purely label-location based indexer for selection by label.
35683567
35693568 Notes
35703569 -----
@@ -3794,6 +3793,19 @@ def sample(self, n=None, frac=None, replace=False, weights=None,
37943793 40 0.823173 -0.078816 1.009536 1.015108
37953794 15 1.421154 -0.055301 -1.922594 -0.019696
37963795 6 -0.148339 0.832938 1.787600 -1.383767
3796+
3797+ You can use `random state` for reproducibility:
3798+
3799+ >>> df.sample(random_state=1)
3800+ A B C D
3801+ 37 -2.027662 0.103611 0.237496 -0.165867
3802+ 43 -0.259323 -0.583426 1.516140 -0.479118
3803+ 12 -1.686325 -0.579510 0.985195 -0.460286
3804+ 8 1.167946 0.429082 1.215742 -1.636041
3805+ 9 1.197475 -0.864188 1.554031 -1.505264
3806+
3807+
3808+
37973809 """
37983810
37993811 if axis is None :
0 commit comments