Skip to content

Commit f37a6a2

Browse files
ottiPjreback
ottiP
authored andcommitted
DOC: Improved the docstring of pandas.Series.filter (#20148)
1 parent 3dd0920 commit f37a6a2

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

pandas/core/generic.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -3924,41 +3924,40 @@ def filter(self, items=None, like=None, regex=None, axis=None):
39243924
Parameters
39253925
----------
39263926
items : list-like
3927-
List of info axis to restrict to (must not all be present)
3927+
List of axis to restrict to (must not all be present).
39283928
like : string
3929-
Keep info axis where "arg in col == True"
3929+
Keep axis where "arg in col == True".
39303930
regex : string (regular expression)
3931-
Keep info axis with re.search(regex, col) == True
3931+
Keep axis with re.search(regex, col) == True.
39323932
axis : int or string axis name
39333933
The axis to filter on. By default this is the info axis,
3934-
'index' for Series, 'columns' for DataFrame
3934+
'index' for Series, 'columns' for DataFrame.
39353935
39363936
Returns
39373937
-------
39383938
same type as input object
39393939
39403940
Examples
39413941
--------
3942-
>>> df
3943-
one two three
3944-
mouse 1 2 3
3945-
rabbit 4 5 6
3942+
>>> df = pd.DataFrame(np.array(([1,2,3], [4,5,6])),
3943+
... index=['mouse', 'rabbit'],
3944+
... columns=['one', 'two', 'three'])
39463945
39473946
>>> # select columns by name
39483947
>>> df.filter(items=['one', 'three'])
3949-
one three
3948+
one three
39503949
mouse 1 3
39513950
rabbit 4 6
39523951
39533952
>>> # select columns by regular expression
39543953
>>> df.filter(regex='e$', axis=1)
3955-
one three
3954+
one three
39563955
mouse 1 3
39573956
rabbit 4 6
39583957
39593958
>>> # select rows containing 'bbi'
39603959
>>> df.filter(like='bbi', axis=0)
3961-
one two three
3960+
one two three
39623961
rabbit 4 5 6
39633962
39643963
See Also

0 commit comments

Comments
 (0)