@@ -53,7 +53,7 @@ def _make_flex_doc(op_name, typ):
53
53
return doc
54
54
55
55
56
- _add_example_SERIES = """
56
+ _common_examples_algebra_SERIES = """
57
57
Examples
58
58
--------
59
59
>>> a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
@@ -69,33 +69,44 @@ def _make_flex_doc(op_name, typ):
69
69
b NaN
70
70
d 1.0
71
71
e 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"""
81
73
82
- _sub_example_SERIES = """
74
+ _common_examples_comparison_SERIES = """
83
75
Examples
84
76
--------
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 '])
86
78
>>> a
87
79
a 1.0
88
80
b 1.0
89
81
c 1.0
90
82
d NaN
83
+ e 1.0
91
84
dtype: 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 '])
93
86
>>> 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
96
101
d 1.0
97
102
e NaN
98
103
dtype: float64
104
+ """
105
+ )
106
+
107
+ _sub_example_SERIES = (
108
+ _common_examples_algebra_SERIES
109
+ + """
99
110
>>> a.subtract(b, fill_value=0)
100
111
a 0.0
101
112
b 1.0
@@ -104,24 +115,11 @@ def _make_flex_doc(op_name, typ):
104
115
e NaN
105
116
dtype: float64
106
117
"""
118
+ )
107
119
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
+ + """
125
123
>>> a.multiply(b, fill_value=0)
126
124
a 1.0
127
125
b 0.0
@@ -130,24 +128,11 @@ def _make_flex_doc(op_name, typ):
130
128
e NaN
131
129
dtype: float64
132
130
"""
131
+ )
133
132
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
+ + """
151
136
>>> a.divide(b, fill_value=0)
152
137
a 1.0
153
138
b inf
@@ -156,24 +141,11 @@ def _make_flex_doc(op_name, typ):
156
141
e NaN
157
142
dtype: float64
158
143
"""
144
+ )
159
145
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
+ + """
177
149
>>> a.floordiv(b, fill_value=0)
178
150
a 1.0
179
151
b NaN
@@ -182,24 +154,11 @@ def _make_flex_doc(op_name, typ):
182
154
e NaN
183
155
dtype: float64
184
156
"""
157
+ )
185
158
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
+ + """
203
162
>>> a.mod(b, fill_value=0)
204
163
a 0.0
205
164
b NaN
@@ -208,23 +167,10 @@ def _make_flex_doc(op_name, typ):
208
167
e NaN
209
168
dtype: float64
210
169
"""
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
+ + """
228
174
>>> a.pow(b, fill_value=0)
229
175
a 1.0
230
176
b 1.0
@@ -233,6 +179,89 @@ def _make_flex_doc(op_name, typ):
233
179
e NaN
234
180
dtype: float64
235
181
"""
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
+ )
236
265
237
266
_returns_series = """Series\n The result of the operation."""
238
267
@@ -306,42 +335,42 @@ def _make_flex_doc(op_name, typ):
306
335
"op" : "==" ,
307
336
"desc" : "Equal to" ,
308
337
"reverse" : None ,
309
- "series_examples" : None ,
338
+ "series_examples" : _eq_example_SERIES ,
310
339
"series_returns" : _returns_series ,
311
340
},
312
341
"ne" : {
313
342
"op" : "!=" ,
314
343
"desc" : "Not equal to" ,
315
344
"reverse" : None ,
316
- "series_examples" : None ,
345
+ "series_examples" : _ne_example_SERIES ,
317
346
"series_returns" : _returns_series ,
318
347
},
319
348
"lt" : {
320
349
"op" : "<" ,
321
350
"desc" : "Less than" ,
322
351
"reverse" : None ,
323
- "series_examples" : None ,
352
+ "series_examples" : _lt_example_SERIES ,
324
353
"series_returns" : _returns_series ,
325
354
},
326
355
"le" : {
327
356
"op" : "<=" ,
328
357
"desc" : "Less than or equal to" ,
329
358
"reverse" : None ,
330
- "series_examples" : None ,
359
+ "series_examples" : _le_example_SERIES ,
331
360
"series_returns" : _returns_series ,
332
361
},
333
362
"gt" : {
334
363
"op" : ">" ,
335
364
"desc" : "Greater than" ,
336
365
"reverse" : None ,
337
- "series_examples" : None ,
366
+ "series_examples" : _gt_example_SERIES ,
338
367
"series_returns" : _returns_series ,
339
368
},
340
369
"ge" : {
341
370
"op" : ">=" ,
342
371
"desc" : "Greater than or equal to" ,
343
372
"reverse" : None ,
344
- "series_examples" : None ,
373
+ "series_examples" : _ge_example_SERIES ,
345
374
"series_returns" : _returns_series ,
346
375
},
347
376
}
0 commit comments