@@ -53,7 +53,7 @@ def _make_flex_doc(op_name, typ):
5353 return doc
5454
5555
56- _add_example_SERIES = """
56+ _common_examples_algebra_SERIES = """
5757Examples
5858--------
5959>>> a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
@@ -69,33 +69,44 @@ def _make_flex_doc(op_name, typ):
6969b NaN
7070d 1.0
7171e NaN
72- dtype: float64
73- >>> a.add(b, fill_value=0)
74- a 2.0
75- b 1.0
76- c 1.0
77- d 1.0
78- e NaN
79- dtype: float64
80- """
72+ dtype: float64"""
8173
82- _sub_example_SERIES = """
74+ _common_examples_comparison_SERIES = """
8375Examples
8476--------
85- >>> a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
77+ >>> a = pd.Series([1, 1, 1, np.nan, 1 ], index=['a', 'b', 'c', 'd', 'e '])
8678>>> a
8779a 1.0
8880b 1.0
8981c 1.0
9082d NaN
83+ e 1.0
9184dtype: float64
92- >>> b = pd.Series([1, np.nan, 1 , np.nan], index=['a', 'b', 'd', 'e '])
85+ >>> b = pd.Series([0, 1, 2 , np.nan, 1 ], index=['a', 'b', 'c', ' d', 'f '])
9386>>> b
94- a 1.0
95- b NaN
87+ a 0.0
88+ b 1.0
89+ c 2.0
90+ d NaN
91+ f 1.0
92+ dtype: float64"""
93+
94+ _add_example_SERIES = (
95+ _common_examples_algebra_SERIES
96+ + """
97+ >>> a.add(b, fill_value=0)
98+ a 2.0
99+ b 1.0
100+ c 1.0
96101d 1.0
97102e NaN
98103dtype: float64
104+ """
105+ )
106+
107+ _sub_example_SERIES = (
108+ _common_examples_algebra_SERIES
109+ + """
99110>>> a.subtract(b, fill_value=0)
100111a 0.0
101112b 1.0
@@ -104,24 +115,11 @@ def _make_flex_doc(op_name, typ):
104115e NaN
105116dtype: float64
106117"""
118+ )
107119
108- _mul_example_SERIES = """
109- Examples
110- --------
111- >>> a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
112- >>> a
113- a 1.0
114- b 1.0
115- c 1.0
116- d NaN
117- dtype: float64
118- >>> b = pd.Series([1, np.nan, 1, np.nan], index=['a', 'b', 'd', 'e'])
119- >>> b
120- a 1.0
121- b NaN
122- d 1.0
123- e NaN
124- dtype: float64
120+ _mul_example_SERIES = (
121+ _common_examples_algebra_SERIES
122+ + """
125123>>> a.multiply(b, fill_value=0)
126124a 1.0
127125b 0.0
@@ -130,24 +128,11 @@ def _make_flex_doc(op_name, typ):
130128e NaN
131129dtype: float64
132130"""
131+ )
133132
134- _div_example_SERIES = """
135- Examples
136- --------
137- >>> a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
138- >>> a
139- a 1.0
140- b 1.0
141- c 1.0
142- d NaN
143- dtype: float64
144- >>> b = pd.Series([1, np.nan, 1, np.nan], index=['a', 'b', 'd', 'e'])
145- >>> b
146- a 1.0
147- b NaN
148- d 1.0
149- e NaN
150- dtype: float64
133+ _div_example_SERIES = (
134+ _common_examples_algebra_SERIES
135+ + """
151136>>> a.divide(b, fill_value=0)
152137a 1.0
153138b inf
@@ -156,24 +141,11 @@ def _make_flex_doc(op_name, typ):
156141e NaN
157142dtype: float64
158143"""
144+ )
159145
160- _floordiv_example_SERIES = """
161- Examples
162- --------
163- >>> a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
164- >>> a
165- a 1.0
166- b 1.0
167- c 1.0
168- d NaN
169- dtype: float64
170- >>> b = pd.Series([1, np.nan, 1, np.nan], index=['a', 'b', 'd', 'e'])
171- >>> b
172- a 1.0
173- b NaN
174- d 1.0
175- e NaN
176- dtype: float64
146+ _floordiv_example_SERIES = (
147+ _common_examples_algebra_SERIES
148+ + """
177149>>> a.floordiv(b, fill_value=0)
178150a 1.0
179151b NaN
@@ -182,24 +154,11 @@ def _make_flex_doc(op_name, typ):
182154e NaN
183155dtype: float64
184156"""
157+ )
185158
186- _mod_example_SERIES = """
187- Examples
188- --------
189- >>> a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
190- >>> a
191- a 1.0
192- b 1.0
193- c 1.0
194- d NaN
195- dtype: float64
196- >>> b = pd.Series([1, np.nan, 1, np.nan], index=['a', 'b', 'd', 'e'])
197- >>> b
198- a 1.0
199- b NaN
200- d 1.0
201- e NaN
202- dtype: float64
159+ _mod_example_SERIES = (
160+ _common_examples_algebra_SERIES
161+ + """
203162>>> a.mod(b, fill_value=0)
204163a 0.0
205164b NaN
@@ -208,23 +167,10 @@ def _make_flex_doc(op_name, typ):
208167e NaN
209168dtype: float64
210169"""
211- _pow_example_SERIES = """
212- Examples
213- --------
214- >>> a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
215- >>> a
216- a 1.0
217- b 1.0
218- c 1.0
219- d NaN
220- dtype: float64
221- >>> b = pd.Series([1, np.nan, 1, np.nan], index=['a', 'b', 'd', 'e'])
222- >>> b
223- a 1.0
224- b NaN
225- d 1.0
226- e NaN
227- dtype: float64
170+ )
171+ _pow_example_SERIES = (
172+ _common_examples_algebra_SERIES
173+ + """
228174>>> a.pow(b, fill_value=0)
229175a 1.0
230176b 1.0
@@ -233,6 +179,89 @@ def _make_flex_doc(op_name, typ):
233179e NaN
234180dtype: float64
235181"""
182+ )
183+
184+ _ne_example_SERIES = (
185+ _common_examples_algebra_SERIES
186+ + """
187+ >>> a.ne(b, fill_value=0)
188+ a False
189+ b True
190+ c True
191+ d True
192+ e True
193+ dtype: bool
194+ """
195+ )
196+
197+ _eq_example_SERIES = (
198+ _common_examples_algebra_SERIES
199+ + """
200+ >>> a.eq(b, fill_value=0)
201+ a True
202+ b False
203+ c False
204+ d False
205+ e False
206+ dtype: bool
207+ """
208+ )
209+
210+ _lt_example_SERIES = (
211+ _common_examples_comparison_SERIES
212+ + """
213+ >>> a.lt(b, fill_value=0)
214+ a False
215+ b False
216+ c True
217+ d False
218+ e False
219+ f True
220+ dtype: bool
221+ """
222+ )
223+
224+ _le_example_SERIES = (
225+ _common_examples_comparison_SERIES
226+ + """
227+ >>> a.le(b, fill_value=0)
228+ a False
229+ b True
230+ c True
231+ d False
232+ e False
233+ f True
234+ dtype: bool
235+ """
236+ )
237+
238+ _gt_example_SERIES = (
239+ _common_examples_comparison_SERIES
240+ + """
241+ >>> a.gt(b, fill_value=0)
242+ a True
243+ b False
244+ c False
245+ d False
246+ e True
247+ f False
248+ dtype: bool
249+ """
250+ )
251+
252+ _ge_example_SERIES = (
253+ _common_examples_comparison_SERIES
254+ + """
255+ >>> a.ge(b, fill_value=0)
256+ a True
257+ b True
258+ c False
259+ d False
260+ e True
261+ f False
262+ dtype: bool
263+ """
264+ )
236265
237266_returns_series = """Series\n The result of the operation."""
238267
@@ -306,42 +335,42 @@ def _make_flex_doc(op_name, typ):
306335 "op" : "==" ,
307336 "desc" : "Equal to" ,
308337 "reverse" : None ,
309- "series_examples" : None ,
338+ "series_examples" : _eq_example_SERIES ,
310339 "series_returns" : _returns_series ,
311340 },
312341 "ne" : {
313342 "op" : "!=" ,
314343 "desc" : "Not equal to" ,
315344 "reverse" : None ,
316- "series_examples" : None ,
345+ "series_examples" : _ne_example_SERIES ,
317346 "series_returns" : _returns_series ,
318347 },
319348 "lt" : {
320349 "op" : "<" ,
321350 "desc" : "Less than" ,
322351 "reverse" : None ,
323- "series_examples" : None ,
352+ "series_examples" : _lt_example_SERIES ,
324353 "series_returns" : _returns_series ,
325354 },
326355 "le" : {
327356 "op" : "<=" ,
328357 "desc" : "Less than or equal to" ,
329358 "reverse" : None ,
330- "series_examples" : None ,
359+ "series_examples" : _le_example_SERIES ,
331360 "series_returns" : _returns_series ,
332361 },
333362 "gt" : {
334363 "op" : ">" ,
335364 "desc" : "Greater than" ,
336365 "reverse" : None ,
337- "series_examples" : None ,
366+ "series_examples" : _gt_example_SERIES ,
338367 "series_returns" : _returns_series ,
339368 },
340369 "ge" : {
341370 "op" : ">=" ,
342371 "desc" : "Greater than or equal to" ,
343372 "reverse" : None ,
344- "series_examples" : None ,
373+ "series_examples" : _ge_example_SERIES ,
345374 "series_returns" : _returns_series ,
346375 },
347376}
0 commit comments