@@ -3525,46 +3525,45 @@ def filter(self, items=None, like=None, regex=None, axis=None):
3525
3525
Parameters
3526
3526
----------
3527
3527
items : list-like
3528
- List of info axis to restrict to (must not all be present)
3528
+ List of axis to restrict to (must not all be present).
3529
3529
like : string
3530
- Keep info axis where "arg in col == True"
3530
+ Keep axis where "arg in col == True".
3531
3531
regex : string (regular expression)
3532
- Keep info axis with re.search(regex, col) == True
3532
+ Keep axis with re.search(regex, col) == True.
3533
3533
axis : int or string axis name
3534
3534
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.
3536
3536
3537
3537
Returns
3538
3538
-------
3539
3539
same type as input object
3540
3540
3541
3541
Examples
3542
3542
--------
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'])
3547
3546
3548
3547
>>> # select columns by name
3549
3548
>>> df.filter(items=['one', 'three'])
3550
- one three
3549
+ one three
3551
3550
mouse 1 3
3552
3551
rabbit 4 6
3553
3552
3554
3553
>>> # select columns by regular expression
3555
3554
>>> df.filter(regex='e$', axis=1)
3556
- one three
3555
+ one three
3557
3556
mouse 1 3
3558
3557
rabbit 4 6
3559
3558
3560
3559
>>> # select rows containing 'bbi'
3561
3560
>>> df.filter(like='bbi', axis=0)
3562
- one two three
3561
+ one two three
3563
3562
rabbit 4 5 6
3564
3563
3565
3564
See Also
3566
3565
--------
3567
- pandas.DataFrame.loc
3566
+ pandas.DataFrame.loc : Label-based indexer.
3568
3567
3569
3568
Notes
3570
3569
-----
0 commit comments