Skip to content

DOC/REF: Rolling/Expanding/EWM docstrings #39219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
85a6189
Create new system for rolling docs
mroeschke Jan 3, 2021
213e19a
Add doc decorators to all rolling methods
mroeschke Jan 4, 2021
d0457d6
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 14, 2021
20f6f96
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 14, 2021
aab5d08
Remove redundant Notes section
mroeschke Jan 15, 2021
0c99293
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 15, 2021
d0ebf56
Add new template for numba params
mroeschke Jan 15, 2021
d6252c5
Remove old shared docs method
mroeschke Jan 15, 2021
41a6cf9
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 16, 2021
593329e
Fix small typos in docstrings
mroeschke Jan 16, 2021
2a07a0b
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 17, 2021
1a2c079
Move versionadded to notes
mroeschke Jan 17, 2021
d07c100
try fixing count?
mroeschke Jan 17, 2021
e40916e
Capitalize summary name
mroeschke Jan 17, 2021
6e7a525
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 17, 2021
8fd88b3
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 17, 2021
ec33dbc
Fix docstring validation errors
mroeschke Jan 18, 2021
f1716db
Fix docbuild warnings
mroeschke Jan 18, 2021
d1d1ae3
More docstring validation fixes
mroeschke Jan 18, 2021
e48e535
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 18, 2021
77ce55c
Fix docstring for expanding sum
mroeschke Jan 18, 2021
db38e9b
Refactor doc templating for rolling
mroeschke Jan 20, 2021
768cbb1
Refactor expanding docstrings
mroeschke Jan 20, 2021
0b443de
Refactor ewm docstrings
mroeschke Jan 20, 2021
76f86e0
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 20, 2021
10e4820
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 21, 2021
32ee31f
Fix some local docstring warnings
mroeschke Jan 21, 2021
a432393
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 21, 2021
1fcc495
Truncate empty string at the end
mroeschke Jan 21, 2021
edcb1c3
Remove trailing extra newline
mroeschke Jan 21, 2021
69f993c
Fix example for doctest
mroeschke Jan 21, 2021
2b95970
Fix another agg docstring
mroeschke Jan 21, 2021
b78daf0
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 21, 2021
12a9364
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 25, 2021
46be73c
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 25, 2021
6efdfec
Add ddof param to docs
mroeschke Jan 25, 2021
3a18ca7
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 26, 2021
4fe4c65
Fix NumPy and SciPy references
mroeschke Jan 26, 2021
0c30c26
Merge remote-tracking branch 'upstream/master' into ref/rolling_docs
mroeschke Jan 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions pandas/core/window/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,6 @@
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries

from pandas.core.indexes.api import MultiIndex
from pandas.core.shared_docs import _shared_docs

_shared_docs = dict(**_shared_docs)
_doc_template = """
Returns
-------
Series or DataFrame
Return type is determined by the caller.

See Also
--------
pandas.Series.%(name)s : Calling object with Series data.
pandas.DataFrame.%(name)s : Calling object with DataFrame data.
pandas.Series.%(func_name)s : Similar method for Series.
pandas.DataFrame.%(func_name)s : Similar method for DataFrame.
"""


def flex_binary_moment(arg1, arg2, f, pairwise=False):
Expand Down
119 changes: 119 additions & 0 deletions pandas/core/window/doc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
"""Any shareable docstring components for rolling/expanding/ewm"""
from textwrap import dedent

from pandas.core.shared_docs import _shared_docs

_shared_docs = dict(**_shared_docs)


def create_section_header(header: str) -> str:
"""Create numpydoc section header"""
return "\n".join((header, "-" * len(header))) + "\n"


template_header = "Calculate the {window_method} {aggregation_description}.\n\n"

template_returns = dedent(
"""
Series or DataFrame
Return type is the same as the original object.\n
"""
).replace("\n", "", 1)

template_see_also = dedent(
"""
pandas.Series.{window_method} : Calling {window_method} with Series data.
pandas.DataFrame.{window_method} : Calling {window_method} with DataFrames.
pandas.Series.{agg_method} : Aggregating {agg_method} for Series.
pandas.DataFrame.{agg_method} : Aggregating {agg_method} for DataFrame.\n
"""
).replace("\n", "", 1)

args_compat = dedent(
"""
*args
For NumPy compatibility and will not have an effect on the result.\n
"""
).replace("\n", "", 1)

kwargs_compat = dedent(
"""
**kwargs
For NumPy compatibility and will not have an effect on the result.\n
"""
).replace("\n", "", 1)

kwargs_scipy = dedent(
"""
**kwargs
Keyword arguments to configure the ``SciPy`` weighted window type.\n
"""
).replace("\n", "", 1)

window_apply_parameters = dedent(
"""
func : function
Must produce a single value from an ndarray input if ``raw=True``
or a single value from a Series if ``raw=False``. Can also accept a
Numba JIT function with ``engine='numba'`` specified.

.. versionchanged:: 1.0.0

raw : bool, default None
* ``False`` : passes each row or column as a Series to the
function.
* ``True`` : the passed function will receive ndarray
objects instead.
If you are just applying a NumPy reduction function this will
achieve much better performance.

engine : str, default None
* ``'cython'`` : Runs rolling apply through C-extensions from cython.
* ``'numba'`` : Runs rolling apply through JIT compiled code from numba.
Only available when ``raw`` is set to ``True``.
* ``None`` : Defaults to ``'cython'`` or globally setting ``compute.use_numba``

.. versionadded:: 1.0.0

engine_kwargs : dict, default None
* For ``'cython'`` engine, there are no accepted ``engine_kwargs``
* For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
and ``parallel`` dictionary keys. The values must either be ``True`` or
``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
``{{'nopython': True, 'nogil': False, 'parallel': False}}`` and will be
applied to both the ``func`` and the ``apply`` rolling aggregation.

.. versionadded:: 1.0.0

args : tuple, default None
Positional arguments to be passed into func.

kwargs : dict, default None
Keyword arguments to be passed into func.\n
"""
).replace("\n", "", 1)

numba_notes = (
"See :ref:`window.numba_engine` for extended documentation "
"and performance considerations for the Numba engine.\n"
)

window_agg_numba_parameters = dedent(
"""
engine : str, default None
* ``'cython'`` : Runs the operation through C-extensions from cython.
* ``'numba'`` : Runs the operation through JIT compiled code from numba.
* ``None`` : Defaults to ``'cython'`` or globally setting ``compute.use_numba``

.. versionadded:: 1.3.0

engine_kwargs : dict, default None
* For ``'cython'`` engine, there are no accepted ``engine_kwargs``
* For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
and ``parallel`` dictionary keys. The values must either be ``True`` or
``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
``{{'nopython': True, 'nogil': False, 'parallel': False}}``

.. versionadded:: 1.3.0\n
"""
).replace("\n", "", 1)
Loading