From 82d5861e2e6c769498de6a5085ab2e63bbf37b94 Mon Sep 17 00:00:00 2001 From: kurtiskerstein Date: Thu, 15 Mar 2018 10:15:09 -0500 Subject: [PATCH 1/2] Added "..." to examples for wrap overflow --- pandas/core/ops.py | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/pandas/core/ops.py b/pandas/core/ops.py index 6c6a54993b669..c9c725f4fe252 100644 --- a/pandas/core/ops.py +++ b/pandas/core/ops.py @@ -345,7 +345,7 @@ def _get_op_name(op, special): _add_example_FRAME = """ >>> a = pd.DataFrame([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'], - columns=['one']) +... columns=['one']) >>> a one a 1.0 @@ -353,8 +353,8 @@ def _get_op_name(op, special): c 1.0 d NaN >>> b = pd.DataFrame(dict(one=[1, np.nan, 1, np.nan], - two=[np.nan, 2, np.nan, 2]), - index=['a', 'b', 'd', 'e']) +... two=[np.nan, 2, np.nan, 2]), +... index=['a', 'b', 'd', 'e']) >>> b one two a 1.0 NaN @@ -370,16 +370,44 @@ def _get_op_name(op, special): e NaN 2.0 """ +_sub_example_FRAME = """ +>>> a = pd.DataFrame([2, 1, 1, np.nan], index=['a', 'b', 'c', 'd'], +... columns=['one']) +>>> a + one +a 2.0 +b 1.0 +c 1.0 +d NaN +>>> b = pd.DataFrame(dict(one=[1, np.nan, 1, np.nan], +... two=[3, 2, np.nan, 2]), +... index=['a', 'b', 'd', 'e']) +>>> b + one two +a 1.0 3.0 +b NaN 2.0 +d 1.0 NaN +e NaN 2.0 +>>> a.sub(b, fill_value=0) + one two +a 1.0 -3.0 +b 1.0 -2.0 +c 1.0 NaN +d -1.0 NaN +e NaN -2.0 +""" + _op_descriptions = { # Arithmetic Operators 'add': {'op': '+', 'desc': 'Addition', 'reverse': 'radd', 'df_examples': _add_example_FRAME}, + # Subtraction Operators 'sub': {'op': '-', 'desc': 'Subtraction', 'reverse': 'rsub', - 'df_examples': None}, + 'df_examples': _sub_example_FRAME}, 'mul': {'op': '*', 'desc': 'Multiplication', 'reverse': 'rmul', From 4141e1eca4da9eda39db68f8aa2c0cc9fe6281a1 Mon Sep 17 00:00:00 2001 From: kurtiskerstein Date: Thu, 15 Mar 2018 17:11:51 -0500 Subject: [PATCH 2/2] remove spacing for params --- pandas/core/ops.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pandas/core/ops.py b/pandas/core/ops.py index 00ce6bd953a72..e14f82906cd06 100644 --- a/pandas/core/ops.py +++ b/pandas/core/ops.py @@ -354,7 +354,7 @@ def _get_op_name(op, special): d NaN >>> b = pd.DataFrame(dict(one=[1, np.nan, 1, np.nan], ... two=[np.nan, 2, np.nan, 2]), -... index=['a', 'b', 'd', 'e']) +... index=['a', 'b', 'd', 'e']) >>> b one two a 1.0 NaN @@ -381,7 +381,7 @@ def _get_op_name(op, special): d NaN >>> b = pd.DataFrame(dict(one=[1, np.nan, 1, np.nan], ... two=[3, 2, np.nan, 2]), -... index=['a', 'b', 'd', 'e']) +... index=['a', 'b', 'd', 'e']) >>> b one two a 1.0 3.0 @@ -403,7 +403,6 @@ def _get_op_name(op, special): 'desc': 'Addition', 'reverse': 'radd', 'df_examples': _add_example_FRAME}, - # Subtraction Operators 'sub': {'op': '-', 'desc': 'Subtraction', 'reverse': 'rsub',