Skip to content

Commit 73dad5b

Browse files
author
ottiP
committed
DOC: Improved the docstring of pandas.Series.filter
1 parent 840d432 commit 73dad5b

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

pandas/core/generic.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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 axis to restrict to (must not all be present).
35293529
like : string
3530-
Keep info axis where "arg in col == True"
3530+
Keep axis where "arg in col == True".
35313531
regex : string (regular expression)
3532-
Keep info axis with re.search(regex, col) == True
3532+
Keep 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 : Label-based indexer.
35683567
35693568
Notes
35703569
-----

0 commit comments

Comments
 (0)