From 73dad5b0aa1a5b87f5349b055ba29b6c6b634153 Mon Sep 17 00:00:00 2001 From: ottiP Date: Sat, 10 Mar 2018 15:13:04 +0100 Subject: [PATCH 1/2] DOC: Improved the docstring of pandas.Series.filter --- pandas/core/generic.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index a893b2ba1a189..e44c56383ab0b 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3525,14 +3525,14 @@ def filter(self, items=None, like=None, regex=None, axis=None): Parameters ---------- items : list-like - List of info axis to restrict to (must not all be present) + List of axis to restrict to (must not all be present). like : string - Keep info axis where "arg in col == True" + Keep axis where "arg in col == True". regex : string (regular expression) - Keep info axis with re.search(regex, col) == True + Keep axis with re.search(regex, col) == True. axis : int or string axis name The axis to filter on. By default this is the info axis, - 'index' for Series, 'columns' for DataFrame + 'index' for Series, 'columns' for DataFrame. Returns ------- @@ -3540,31 +3540,30 @@ def filter(self, items=None, like=None, regex=None, axis=None): Examples -------- - >>> df - one two three - mouse 1 2 3 - rabbit 4 5 6 + >>> df = pd.DataFrame(np.array(([1,2,3], [4,5,6])), + ... index=['mouse', 'rabbit'], + ... columns=['one', 'two', 'three']) >>> # select columns by name >>> df.filter(items=['one', 'three']) - one three + one three mouse 1 3 rabbit 4 6 >>> # select columns by regular expression >>> df.filter(regex='e$', axis=1) - one three + one three mouse 1 3 rabbit 4 6 >>> # select rows containing 'bbi' >>> df.filter(like='bbi', axis=0) - one two three + one two three rabbit 4 5 6 See Also -------- - pandas.DataFrame.loc + pandas.DataFrame.loc : Label-based indexer. Notes ----- From 7257a410b968efb66ae7ae8111bd3ec49b2faeaf Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Sat, 7 Jul 2018 09:43:54 -0500 Subject: [PATCH 2/2] Small cleanup --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index d102f3f6d8ede..33e0278755c90 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3872,7 +3872,7 @@ def filter(self, items=None, like=None, regex=None, axis=None): See Also -------- - pandas.DataFrame.loc : Label-based indexer. + pandas.DataFrame.loc Notes -----