Skip to content

Commit 51a6f0d

Browse files
committed
Extend docstrings of dunder methods, so autodoc table looks reasonable.
1 parent 3fe6b68 commit 51a6f0d

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

spec/API_specification/dataframe_api/dataframe_object.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ def set_column(self, label: str, value: Column) -> DataFrame:
165165

166166
def __eq__(self, other: DataFrame | "Scalar") -> DataFrame:
167167
"""
168+
Compare for equality.
169+
168170
Parameters
169171
----------
170172
other : DataFrame or Scalar
@@ -180,6 +182,8 @@ def __eq__(self, other: DataFrame | "Scalar") -> DataFrame:
180182

181183
def __ne__(self, other: DataFrame | "Scalar") -> DataFrame:
182184
"""
185+
Compare for non-equality.
186+
183187
Parameters
184188
----------
185189
other : DataFrame or Scalar
@@ -195,6 +199,8 @@ def __ne__(self, other: DataFrame | "Scalar") -> DataFrame:
195199

196200
def __ge__(self, other: DataFrame | "Scalar") -> DataFrame:
197201
"""
202+
Compare for "greater than or equal to" `other`.
203+
198204
Parameters
199205
----------
200206
other : DataFrame or Scalar
@@ -210,6 +216,8 @@ def __ge__(self, other: DataFrame | "Scalar") -> DataFrame:
210216

211217
def __gt__(self, other: DataFrame | "Scalar") -> DataFrame:
212218
"""
219+
Compare for "greater than" `other`.
220+
213221
Parameters
214222
----------
215223
other : DataFrame or Scalar
@@ -225,6 +233,8 @@ def __gt__(self, other: DataFrame | "Scalar") -> DataFrame:
225233

226234
def __le__(self, other: DataFrame | "Scalar") -> DataFrame:
227235
"""
236+
Compare for "less than or equal to" `other`.
237+
228238
Parameters
229239
----------
230240
other : DataFrame or Scalar
@@ -240,6 +250,8 @@ def __le__(self, other: DataFrame | "Scalar") -> DataFrame:
240250

241251
def __lt__(self, other: DataFrame | "Scalar") -> DataFrame:
242252
"""
253+
Compare for "less than" `other`.
254+
243255
Parameters
244256
----------
245257
other : DataFrame or Scalar
@@ -255,6 +267,8 @@ def __lt__(self, other: DataFrame | "Scalar") -> DataFrame:
255267

256268
def __add__(self, other: DataFrame | "Scalar") -> DataFrame:
257269
"""
270+
Add `other` dataframe or scalar to this dataframe.
271+
258272
Parameters
259273
----------
260274
other : DataFrame or Scalar
@@ -270,6 +284,8 @@ def __add__(self, other: DataFrame | "Scalar") -> DataFrame:
270284

271285
def __sub__(self, other: DataFrame | "Scalar") -> DataFrame:
272286
"""
287+
Subtract `other` dataframe or scalar from this dataframe.
288+
273289
Parameters
274290
----------
275291
other : DataFrame or Scalar
@@ -285,6 +301,8 @@ def __sub__(self, other: DataFrame | "Scalar") -> DataFrame:
285301

286302
def __mul__(self, other: DataFrame | "Scalar") -> DataFrame:
287303
"""
304+
Multiply `other` dataframe or scalar with this dataframe.
305+
288306
Parameters
289307
----------
290308
other : DataFrame or Scalar
@@ -300,6 +318,8 @@ def __mul__(self, other: DataFrame | "Scalar") -> DataFrame:
300318

301319
def __truediv__(self, other: DataFrame | "Scalar") -> DataFrame:
302320
"""
321+
Divide this dataframe by `other` dataframe or scalar. True division, returns floats.
322+
303323
Parameters
304324
----------
305325
other : DataFrame or Scalar
@@ -315,6 +335,8 @@ def __truediv__(self, other: DataFrame | "Scalar") -> DataFrame:
315335

316336
def __floordiv__(self, other: DataFrame | "Scalar") -> DataFrame:
317337
"""
338+
Floor-divide (returns integers) this dataframe by `other` dataframe or scalar.
339+
318340
Parameters
319341
----------
320342
other : DataFrame or Scalar
@@ -330,6 +352,8 @@ def __floordiv__(self, other: DataFrame | "Scalar") -> DataFrame:
330352

331353
def __pow__(self, other: DataFrame | "Scalar") -> DataFrame:
332354
"""
355+
Raise this dataframe to the power of `other`.
356+
333357
Parameters
334358
----------
335359
other : DataFrame or Scalar
@@ -345,6 +369,8 @@ def __pow__(self, other: DataFrame | "Scalar") -> DataFrame:
345369

346370
def __mod__(self, other: DataFrame | "Scalar") -> DataFrame:
347371
"""
372+
Return modulus of this dataframe by `other` (`%` operator).
373+
348374
Parameters
349375
----------
350376
other : DataFrame or Scalar
@@ -360,6 +386,8 @@ def __mod__(self, other: DataFrame | "Scalar") -> DataFrame:
360386

361387
def __divmod__(self, other: DataFrame | "Scalar") -> tuple[DataFrame, DataFrame]:
362388
"""
389+
Return quotient and remainder of integer division. See `divmod` builtin function.
390+
363391
Parameters
364392
----------
365393
other : DataFrame or Scalar
@@ -369,8 +397,7 @@ def __divmod__(self, other: DataFrame | "Scalar") -> tuple[DataFrame, DataFrame]
369397
370398
Returns
371399
-------
372-
DataFrame
373-
DataFrame
400+
A tuple of two DataFrame's
374401
"""
375402
...
376403

spec/API_specification/dataframe_object.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ an array object supporting the following Python arithmetic operators.
5959

6060
Arithmetic operators should be defined for a dataframe having real-valued data types.
6161

62+
.. note::
63+
64+
TODO: figure out whether we want to add ``__neg__`` and ``__pos__``, those
65+
are the two missing arithmetic operators.
66+
6267

6368
Comparison Operators
6469
~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)