|
| 1 | +"""Any shareable docstring components for rolling/expanding/ewm""" |
| 2 | +from textwrap import dedent |
| 3 | + |
| 4 | +from pandas.core.shared_docs import _shared_docs |
| 5 | + |
| 6 | +_shared_docs = dict(**_shared_docs) |
| 7 | + |
| 8 | + |
| 9 | +def create_section_header(header: str) -> str: |
| 10 | + """Create numpydoc section header""" |
| 11 | + return "\n".join((header, "-" * len(header))) + "\n" |
| 12 | + |
| 13 | + |
| 14 | +template_header = "Calculate the {window_method} {aggregation_description}.\n\n" |
| 15 | + |
| 16 | +template_returns = dedent( |
| 17 | + """ |
| 18 | + Series or DataFrame |
| 19 | + Return type is the same as the original object.\n |
| 20 | + """ |
| 21 | +).replace("\n", "", 1) |
| 22 | + |
| 23 | +template_see_also = dedent( |
| 24 | + """ |
| 25 | + pandas.Series.{window_method} : Calling {window_method} with Series data. |
| 26 | + pandas.DataFrame.{window_method} : Calling {window_method} with DataFrames. |
| 27 | + pandas.Series.{agg_method} : Aggregating {agg_method} for Series. |
| 28 | + pandas.DataFrame.{agg_method} : Aggregating {agg_method} for DataFrame.\n |
| 29 | + """ |
| 30 | +).replace("\n", "", 1) |
| 31 | + |
| 32 | +args_compat = dedent( |
| 33 | + """ |
| 34 | + *args |
| 35 | + For NumPy compatibility and will not have an effect on the result.\n |
| 36 | + """ |
| 37 | +).replace("\n", "", 1) |
| 38 | + |
| 39 | +kwargs_compat = dedent( |
| 40 | + """ |
| 41 | + **kwargs |
| 42 | + For NumPy compatibility and will not have an effect on the result.\n |
| 43 | + """ |
| 44 | +).replace("\n", "", 1) |
| 45 | + |
| 46 | +kwargs_scipy = dedent( |
| 47 | + """ |
| 48 | + **kwargs |
| 49 | + Keyword arguments to configure the ``SciPy`` weighted window type.\n |
| 50 | + """ |
| 51 | +).replace("\n", "", 1) |
| 52 | + |
| 53 | +window_apply_parameters = dedent( |
| 54 | + """ |
| 55 | + func : function |
| 56 | + Must produce a single value from an ndarray input if ``raw=True`` |
| 57 | + or a single value from a Series if ``raw=False``. Can also accept a |
| 58 | + Numba JIT function with ``engine='numba'`` specified. |
| 59 | +
|
| 60 | + .. versionchanged:: 1.0.0 |
| 61 | +
|
| 62 | + raw : bool, default None |
| 63 | + * ``False`` : passes each row or column as a Series to the |
| 64 | + function. |
| 65 | + * ``True`` : the passed function will receive ndarray |
| 66 | + objects instead. |
| 67 | + If you are just applying a NumPy reduction function this will |
| 68 | + achieve much better performance. |
| 69 | +
|
| 70 | + engine : str, default None |
| 71 | + * ``'cython'`` : Runs rolling apply through C-extensions from cython. |
| 72 | + * ``'numba'`` : Runs rolling apply through JIT compiled code from numba. |
| 73 | + Only available when ``raw`` is set to ``True``. |
| 74 | + * ``None`` : Defaults to ``'cython'`` or globally setting ``compute.use_numba`` |
| 75 | +
|
| 76 | + .. versionadded:: 1.0.0 |
| 77 | +
|
| 78 | + engine_kwargs : dict, default None |
| 79 | + * For ``'cython'`` engine, there are no accepted ``engine_kwargs`` |
| 80 | + * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil`` |
| 81 | + and ``parallel`` dictionary keys. The values must either be ``True`` or |
| 82 | + ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is |
| 83 | + ``{{'nopython': True, 'nogil': False, 'parallel': False}}`` and will be |
| 84 | + applied to both the ``func`` and the ``apply`` rolling aggregation. |
| 85 | +
|
| 86 | + .. versionadded:: 1.0.0 |
| 87 | +
|
| 88 | + args : tuple, default None |
| 89 | + Positional arguments to be passed into func. |
| 90 | +
|
| 91 | + kwargs : dict, default None |
| 92 | + Keyword arguments to be passed into func.\n |
| 93 | + """ |
| 94 | +).replace("\n", "", 1) |
| 95 | + |
| 96 | +numba_notes = ( |
| 97 | + "See :ref:`window.numba_engine` for extended documentation " |
| 98 | + "and performance considerations for the Numba engine.\n" |
| 99 | +) |
| 100 | + |
| 101 | +window_agg_numba_parameters = dedent( |
| 102 | + """ |
| 103 | + engine : str, default None |
| 104 | + * ``'cython'`` : Runs the operation through C-extensions from cython. |
| 105 | + * ``'numba'`` : Runs the operation through JIT compiled code from numba. |
| 106 | + * ``None`` : Defaults to ``'cython'`` or globally setting ``compute.use_numba`` |
| 107 | +
|
| 108 | + .. versionadded:: 1.3.0 |
| 109 | +
|
| 110 | + engine_kwargs : dict, default None |
| 111 | + * For ``'cython'`` engine, there are no accepted ``engine_kwargs`` |
| 112 | + * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil`` |
| 113 | + and ``parallel`` dictionary keys. The values must either be ``True`` or |
| 114 | + ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is |
| 115 | + ``{{'nopython': True, 'nogil': False, 'parallel': False}}`` |
| 116 | +
|
| 117 | + .. versionadded:: 1.3.0\n |
| 118 | + """ |
| 119 | +).replace("\n", "", 1) |
0 commit comments