From 8303f9761119c6e24c742a93d1f15a57706ca043 Mon Sep 17 00:00:00 2001 From: frankdupree Date: Fri, 9 Mar 2018 15:37:38 +0100 Subject: [PATCH 1/3] DOC: Improved the docstring of pandas.Series.any --- pandas/core/generic.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index a893b2ba1a189..d2c1d13a419d4 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -7522,7 +7522,7 @@ def _add_numeric_operations(cls): cls.any = _make_logical_function( cls, 'any', name, name2, axis_descr, - 'Return whether any element is True over requested axis', + 'Return whether any element is True over requested axis.', nanops.nanany) cls.all = _make_logical_function( cls, 'all', name, name2, axis_descr, @@ -7784,25 +7784,49 @@ def _doc_parms(cls): %(outname)s : %(name1)s or %(name2)s (if level specified)\n""" _bool_doc = """ - %(desc)s +Returns True if one (or more) elements are non-zero, +not-empty or not-False. + +Also note that a series consisting of different +data types returns the first occurence of the +non-zero, not-empty or not-False element. Parameters ---------- axis : %(axis_descr)s skipna : boolean, default True Exclude NA/null values. If an entire row/column is NA, the result - will be NA + will be NA. level : int or level name, default None If the axis is a MultiIndex (hierarchical), count along a - particular level, collapsing into a %(name1)s + particular level, collapsing into a %(name1)s. bool_only : boolean, default None Include only boolean columns. If None, will attempt to use everything, then use only boolean data. Not implemented for Series. +**kwargs : + Additional keywords have no effect but might be accepted for + compatibility with numpy. Returns ------- -%(outname)s : %(name1)s or %(name2)s (if level specified)\n""" +%(outname)s : %(name1)s or %(name2)s (if level specified) + +Examples +-------- +>>> s1 = pd.Series([1,2,3]) +>>> s1.any() +True + +>>> import numpy as np +>>> s2 = pd.Series([np.NaN,np.NaN,np.NaN]) +>>> s2.any() +False + +>>> s3 = pd.Series([1,2,3,"Hobbit"]) +>>> s3.any() +1 +""" _cnum_doc = """ From 8737e316d73367ffaf35f61200dcd7ebebe854e1 Mon Sep 17 00:00:00 2001 From: frankdupree Date: Fri, 9 Mar 2018 20:59:02 +0100 Subject: [PATCH 2/3] Updates: removed documentation on bug. --- pandas/core/generic.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index d2c1d13a419d4..a118521f0b5ff 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -7785,13 +7785,10 @@ def _doc_parms(cls): _bool_doc = """ %(desc)s + Returns True if one (or more) elements are non-zero, not-empty or not-False. -Also note that a series consisting of different -data types returns the first occurence of the -non-zero, not-empty or not-False element. - Parameters ---------- axis : %(axis_descr)s @@ -7814,18 +7811,14 @@ def _doc_parms(cls): Examples -------- ->>> s1 = pd.Series([1,2,3]) +>>> s1 = pd.Series([1, 2, 3]) >>> s1.any() True >>> import numpy as np ->>> s2 = pd.Series([np.NaN,np.NaN,np.NaN]) +>>> s2 = pd.Series([np.NaN, np.NaN, np.NaN]) >>> s2.any() False - ->>> s3 = pd.Series([1,2,3,"Hobbit"]) ->>> s3.any() -1 """ _cnum_doc = """ From 680f48c2c1ff6b40df1b9d69630da2eb2ddb5078 Mon Sep 17 00:00:00 2001 From: frankdupree Date: Sat, 10 Mar 2018 06:02:49 +0100 Subject: [PATCH 3/3] DOC: Improved the docstring of Series.any() --- pandas/core/generic.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index a118521f0b5ff..6e0a92a3cd93a 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -7801,8 +7801,7 @@ def _doc_parms(cls): bool_only : boolean, default None Include only boolean columns. If None, will attempt to use everything, then use only boolean data. Not implemented for Series. -**kwargs : - Additional keywords have no effect but might be accepted for +**kwargs : Additional keywords have no effect but might be accepted for compatibility with numpy. Returns