@@ -3924,41 +3924,40 @@ def filter(self, items=None, like=None, regex=None, axis=None):
3924
3924
Parameters
3925
3925
----------
3926
3926
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).
3928
3928
like : string
3929
- Keep info axis where "arg in col == True"
3929
+ Keep axis where "arg in col == True".
3930
3930
regex : string (regular expression)
3931
- Keep info axis with re.search(regex, col) == True
3931
+ Keep axis with re.search(regex, col) == True.
3932
3932
axis : int or string axis name
3933
3933
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.
3935
3935
3936
3936
Returns
3937
3937
-------
3938
3938
same type as input object
3939
3939
3940
3940
Examples
3941
3941
--------
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'])
3946
3945
3947
3946
>>> # select columns by name
3948
3947
>>> df.filter(items=['one', 'three'])
3949
- one three
3948
+ one three
3950
3949
mouse 1 3
3951
3950
rabbit 4 6
3952
3951
3953
3952
>>> # select columns by regular expression
3954
3953
>>> df.filter(regex='e$', axis=1)
3955
- one three
3954
+ one three
3956
3955
mouse 1 3
3957
3956
rabbit 4 6
3958
3957
3959
3958
>>> # select rows containing 'bbi'
3960
3959
>>> df.filter(like='bbi', axis=0)
3961
- one two three
3960
+ one two three
3962
3961
rabbit 4 5 6
3963
3962
3964
3963
See Also
0 commit comments