Skip to content

Commit f690016

Browse files
authored
Clean up the html docs for the dataframe API standard (#152)
* Update front page and sections * Use autodoc better to generate dataframe and groupby docs * More autodoc improvements, and cleaning up operator support boilerplate * Finish dealing with operators on dataframes * Fix last warnings, and include Column in the same way as DataFrame * Upgrade Sphinx, sphinx-material and docutils * Remove a few sentences with intra-markdown-file links Resolves the issue with CI not being green due to a bug in Myst
1 parent ce5847f commit f690016

14 files changed

+84
-232
lines changed

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
sphinx==4.3.0
2-
sphinx-material==0.0.30
1+
sphinx==6.2.1
2+
sphinx-material==0.0.35
33
myst-parser
44
sphinx_markdown_tables
55
sphinx_copybutton
6-
docutils<0.18
6+
docutils==0.19
77
sphinx-math-dollar

spec/API_specification/column_object.rst

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,9 @@ Column object
44
=============
55

66
A conforming implementation of the dataframe API standard must provide and
7-
support a column object having the following attributes and methods.
7+
support a column object having the following methods, attributes, and
8+
behavior.
89

9-
-------------------------------------------------
10-
11-
Methods
12-
-------
13-
TODO
14-
15-
..
16-
NOTE: please keep the methods in alphabetical order
17-
18-
.. currentmodule:: dataframe_api
19-
20-
.. autosummary::
21-
:toctree: generated
22-
:template: property.rst
10+
.. currentmodule:: dataframe_api
2311

12+
.. autoclass:: Column

spec/API_specification/dataframe_api/column_object.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44

55
from ._types import dtype
66

7+
8+
__all__ = ['Column']
9+
10+
711
class Column:
12+
"""
13+
Column object
14+
15+
Note that this column object is not meant to be instantiated directly by
16+
users of the library implementing the dataframe API standard. Rather, use
17+
constructor functions or an already-created dataframe object retrieved via
18+
19+
"""
820
@classmethod
921
def from_sequence(cls, sequence: Sequence[object], dtype: dtype) -> Column:
1022
"""

spec/API_specification/dataframe_api/dataframe_object.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,30 @@
1111

1212

1313
class DataFrame:
14+
"""
15+
DataFrame object
16+
17+
Note that this dataframe object is not meant to be instantiated directly by
18+
users of the library implementing the dataframe API standard. Rather, use
19+
constructor functions or an already-created dataframe object retrieved via
20+
21+
**Python operator support**
22+
23+
All arithmetic operators defined by the Python language, except for
24+
``__matmul__``, ``__neg__`` and ``__pos__``, must be supported for
25+
numerical data types.
26+
27+
All comparison operators defined by the Python language must be supported
28+
by the dataframe object for all data types for which those comparisons are
29+
supported by the builtin scalar types corresponding to a data type.
30+
31+
In-place operators must not be supported. All operations on the dataframe
32+
object are out-of-place.
33+
34+
**Methods and Attributes**
35+
36+
"""
37+
1438
@classmethod
1539
def from_dict(cls, data: Mapping[str, Column]) -> DataFrame:
1640
"""

spec/API_specification/dataframe_api/groupby_object.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44
from .dataframe_object import DataFrame
55

66

7+
__all__ = ['GroupBy']
8+
9+
710
class GroupBy:
11+
"""
12+
GroupBy object.
13+
14+
Note that this class is not meant to be constructed by users.
15+
It is returned from `DataFrame.groupby`.
16+
17+
**Methods**
18+
19+
"""
820
def any(self, skip_nulls: bool = True) -> "DataFrame":
921
...
1022

spec/API_specification/dataframe_object.rst

Lines changed: 3 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -4,169 +4,9 @@ Dataframe object
44
================
55

66
A conforming implementation of the dataframe API standard must provide and
7-
support a dataframe object having the following attributes and methods.
8-
9-
-------------------------------------------------
10-
11-
.. _operators:
12-
13-
Operators
14-
---------
15-
16-
A conforming implementation of the dataframe API standard must provide and
17-
support a dataframe object supporting the following Python operators.
18-
19-
Arithmetic Operators
20-
~~~~~~~~~~~~~~~~~~~~
21-
22-
A conforming implementation of the array API standard must provide and support
23-
an array object supporting the following Python arithmetic operators.
24-
25-
- `x1 + x2`: :meth:`.DataFrame.__add__`
26-
27-
- `operator.add(x1, x2) <https://docs.python.org/3/library/operator.html#operator.add>`_
28-
- `operator.__add__(x1, x2) <https://docs.python.org/3/library/operator.html#operator.__add__>`_
29-
30-
- `x1 - x2`: :meth:`.DataFrame.__sub__`
31-
32-
- `operator.sub(x1, x2) <https://docs.python.org/3/library/operator.html#operator.sub>`_
33-
- `operator.__sub__(x1, x2) <https://docs.python.org/3/library/operator.html#operator.__sub__>`_
34-
35-
- `x1 * x2`: :meth:`.DataFrame.__mul__`
36-
37-
- `operator.mul(x1, x2) <https://docs.python.org/3/library/operator.html#operator.mul>`_
38-
- `operator.__mul__(x1, x2) <https://docs.python.org/3/library/operator.html#operator.__mul__>`_
39-
40-
- `x1 / x2`: :meth:`.DataFrame.__truediv__`
41-
42-
- `operator.truediv(x1,x2) <https://docs.python.org/3/library/operator.html#operator.truediv>`_
43-
- `operator.__truediv__(x1, x2) <https://docs.python.org/3/library/operator.html#operator.__truediv__>`_
44-
45-
- `x1 // x2`: :meth:`.DataFrame.__floordiv__`
46-
47-
- `operator.floordiv(x1, x2) <https://docs.python.org/3/library/operator.html#operator.floordiv>`_
48-
- `operator.__floordiv__(x1, x2) <https://docs.python.org/3/library/operator.html#operator.__floordiv__>`_
49-
50-
- `x1 % x2`: :meth:`.DataFrame.__mod__`
51-
52-
- `operator.mod(x1, x2) <https://docs.python.org/3/library/operator.html#operator.mod>`_
53-
- `operator.__mod__(x1, x2) <https://docs.python.org/3/library/operator.html#operator.__mod__>`_
54-
55-
- `x1 ** x2`: :meth:`.DataFrame.__pow__`
56-
57-
- `operator.pow(x1, x2) <https://docs.python.org/3/library/operator.html#operator.pow>`_
58-
- `operator.__pow__(x1, x2) <https://docs.python.org/3/library/operator.html#operator.__pow__>`_
59-
60-
Arithmetic operators should be defined for a dataframe having real-valued data types.
61-
62-
.. note::
63-
64-
TODO: figure out whether we want to add ``__neg__`` and ``__pos__``, those
65-
are the two missing arithmetic operators.
66-
67-
68-
Comparison Operators
69-
~~~~~~~~~~~~~~~~~~~~
70-
71-
A conforming implementation of the dataframe API standard must provide and
72-
support a dataframe object supporting the following Python comparison
73-
operators.
74-
75-
- `x1 < x2`: :meth:`.DataFrame.__lt__`
76-
77-
- `operator.lt(x1, x2) <https://docs.python.org/3/library/operator.html#operator.lt>`_
78-
- `operator.__lt__(x1, x2) <https://docs.python.org/3/library/operator.html#operator.__lt__>`_
79-
80-
- `x1 <= x2`: :meth:`.DataFrame.__le__`
81-
82-
- `operator.le(x1, x2) <https://docs.python.org/3/library/operator.html#operator.le>`_
83-
- `operator.__le__(x1, x2) <https://docs.python.org/3/library/operator.html#operator.__le__>`_
84-
85-
- `x1 > x2`: :meth:`.DataFrame.__gt__`
86-
87-
- `operator.gt(x1, x2) <https://docs.python.org/3/library/operator.html#operator.gt>`_
88-
- `operator.__gt__(x1, x2) <https://docs.python.org/3/library/operator.html#operator.__gt__>`_
89-
90-
- `x1 >= x2`: :meth:`.DataFrame.__ge__`
91-
92-
- `operator.ge(x1, x2) <https://docs.python.org/3/library/operator.html#operator.ge>`_
93-
- `operator.__ge__(x1, x2) <https://docs.python.org/3/library/operator.html#operator.__ge__>`_
94-
95-
- `x1 == x2`: :meth:`.DataFrame.__eq__`
96-
97-
- `operator.eq(x1, x2) <https://docs.python.org/3/library/operator.html#operator.eq>`_
98-
- `operator.__eq__(x1, x2) <https://docs.python.org/3/library/operator.html#operator.__eq__>`_
99-
100-
- `x1 != x2`: :meth:`.DataFrame.__ne__`
101-
102-
- `operator.ne(x1, x2) <https://docs.python.org/3/library/operator.html#operator.ne>`_
103-
- `operator.__ne__(x1, x2) <https://docs.python.org/3/library/operator.html#operator.__ne__>`_
104-
105-
Comparison operators should be defined for dataframes having any data type.
106-
107-
In-place Operators
108-
~~~~~~~~~~~~~~~~~~
109-
110-
TODO
111-
112-
Reflected Operators
113-
~~~~~~~~~~~~~~~~~~~
114-
115-
TODO
116-
117-
Arithmetic Operators
118-
""""""""""""""""""""
119-
120-
- ``__radd__``
121-
- ``__rsub__``
122-
- ``__rmul__``
123-
- ``__rtruediv__``
124-
- ``__rfloordiv__``
125-
- ``__rpow__``
126-
- ``__rmod__``
127-
128-
-------------------------------------------------
7+
support a dataframe object having the following methods, attributes, and
8+
behavior.
1299

13010
.. currentmodule:: dataframe_api
13111

132-
Attributes
133-
----------
134-
135-
TODO
136-
137-
..
138-
NOTE: please keep the attributes in alphabetical order
139-
140-
141-
..
142-
autosummary::
143-
:toctree: generated
144-
:template: property.rst
145-
146-
DataFrame.shape
147-
148-
-------------------------------------------------
149-
150-
Methods
151-
-------
152-
..
153-
NOTE: please keep the methods in alphabetical order
154-
155-
156-
.. autosummary::
157-
:toctree: generated
158-
:template: property.rst
159-
160-
DataFrame.__add__
161-
DataFrame.__eq__
162-
DataFrame.__floordiv__
163-
DataFrame.__ge__
164-
DataFrame.__gt__
165-
DataFrame.__le__
166-
DataFrame.__lt__
167-
DataFrame.__ne__
168-
DataFrame.__mod__
169-
DataFrame.__mul__
170-
DataFrame.__pow__
171-
DataFrame.__sub__
172-
DataFrame.__truediv__
12+
.. autoclass:: DataFrame

spec/API_specification/groupby_object.rst

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,10 @@ Groupby object
44
==============
55

66
A conforming implementation of the dataframe API standard must provide and
7-
support a groupby object having the following attributes and methods.
8-
9-
-------------------------------------------------
10-
11-
Methods
12-
-------
13-
..
14-
NOTE: please keep the methods in alphabetical order
7+
support a groupby object with the following API:
158

169
.. currentmodule:: dataframe_api
1710

18-
.. autosummary::
19-
:toctree: generated
20-
:template: property.rst
11+
.. autoclass:: GroupBy
12+
2113

22-
GroupBy.all
23-
GroupBy.any
24-
GroupBy.max
25-
GroupBy.min
26-
GroupBy.mean
27-
GroupBy.median
28-
GroupBy.prod
29-
GroupBy.std
30-
GroupBy.sum
31-
GroupBy.var

spec/API_specification/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ API specification
44
.. currentmodule:: dataframe_api
55

66
.. toctree::
7-
:caption: API specification
87
:maxdepth: 3
98

109
dataframe_object

spec/api_design_methodology.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Methodology for API design
2+
3+
TODO: describe approach used to construct the API.

spec/benchmark_suite.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

spec/conf.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
# -- Project information -----------------------------------------------------
1919

2020
project = 'Python dataframe API standard'
21-
copyright = '2022, Consortium for Python Data API Standards'
21+
copyright = '2021-, Consortium for Python Data API Standards'
2222
author = 'Consortium for Python Data API Standards'
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '2022.12-DRAFT'
25+
release = '2023.04-DRAFT'
2626

2727

2828
# -- General configuration ---------------------------------------------------
@@ -46,7 +46,15 @@
4646

4747
autosummary_generate = True
4848
autodoc_typehints = 'signature'
49+
autodoc_default_options = {
50+
# 'attributes': True,
51+
'members': True,
52+
'special-members': True,
53+
'undoc-members': True,
54+
'exclude-members': '__annotations__, __dict__,__weakref__,__module__',
55+
}
4956
add_module_names = False
57+
napoleon_numpy_docstring = True
5058
napoleon_custom_sections = [('Returns', 'params_style')]
5159
default_role = 'code'
5260

spec/index.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Python dataframe API standard
22
=============================
33

4+
.. note::
5+
6+
This API standard is still a work in progress, and approaching "minimum
7+
viable product" status, where it's becoming possible to write library code
8+
against it that is dataframe-agnostic. Design discussions are
9+
happening in `this repository <https://github.com/data-apis/dataframe-api>`__.
10+
Participation there is very much welcome.
11+
412
Contents
513
--------
614

@@ -21,9 +29,8 @@ Contents
2129
API_specification/index
2230

2331
.. toctree::
24-
:caption: Methodology and Usage
32+
:caption: Methodology and Tooling
2533
:maxdepth: 1
2634

27-
usage_data
35+
api_design_methodology
2836
verification_test_suite
29-
benchmark_suite

0 commit comments

Comments
 (0)