Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pandas/core/window/doc.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

15 statements  

1"""Any shareable docstring components for rolling/expanding/ewm""" 

2from __future__ import annotations 

3 

4from textwrap import dedent 

5 

6from pandas.core.shared_docs import _shared_docs 

7 

8_shared_docs = dict(**_shared_docs) 

9 

10 

11def create_section_header(header: str) -> str: 

12 """Create numpydoc section header""" 

13 return f"{header}\n{'-' * len(header)}\n" 

14 

15 

16template_header = "\nCalculate the {window_method} {aggregation_description}.\n\n" 

17 

18template_returns = dedent( 

19 """ 

20 Series or DataFrame 

21 Return type is the same as the original object with ``np.float64`` dtype.\n 

22 """ 

23).replace("\n", "", 1) 

24 

25template_see_also = dedent( 

26 """ 

27 pandas.Series.{window_method} : Calling {window_method} with Series data. 

28 pandas.DataFrame.{window_method} : Calling {window_method} with DataFrames. 

29 pandas.Series.{agg_method} : Aggregating {agg_method} for Series. 

30 pandas.DataFrame.{agg_method} : Aggregating {agg_method} for DataFrame.\n 

31 """ 

32).replace("\n", "", 1) 

33 

34kwargs_numeric_only = dedent( 

35 """ 

36 numeric_only : bool, default False 

37 Include only float, int, boolean columns. 

38 

39 .. versionadded:: 1.5.0\n 

40 """ 

41).replace("\n", "", 1) 

42 

43kwargs_scipy = dedent( 

44 """ 

45 **kwargs 

46 Keyword arguments to configure the ``SciPy`` weighted window type.\n 

47 """ 

48).replace("\n", "", 1) 

49 

50window_apply_parameters = dedent( 

51 """ 

52 func : function 

53 Must produce a single value from an ndarray input if ``raw=True`` 

54 or a single value from a Series if ``raw=False``. Can also accept a 

55 Numba JIT function with ``engine='numba'`` specified. 

56 

57 raw : bool, default False 

58 * ``False`` : passes each row or column as a Series to the 

59 function. 

60 * ``True`` : the passed function will receive ndarray 

61 objects instead. 

62 If you are just applying a NumPy reduction function this will 

63 achieve much better performance. 

64 

65 engine : str, default None 

66 * ``'cython'`` : Runs rolling apply through C-extensions from cython. 

67 * ``'numba'`` : Runs rolling apply through JIT compiled code from numba. 

68 Only available when ``raw`` is set to ``True``. 

69 * ``None`` : Defaults to ``'cython'`` or globally setting ``compute.use_numba`` 

70 

71 engine_kwargs : dict, default None 

72 * For ``'cython'`` engine, there are no accepted ``engine_kwargs`` 

73 * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil`` 

74 and ``parallel`` dictionary keys. The values must either be ``True`` or 

75 ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is 

76 ``{{'nopython': True, 'nogil': False, 'parallel': False}}`` and will be 

77 applied to both the ``func`` and the ``apply`` rolling aggregation. 

78 

79 args : tuple, default None 

80 Positional arguments to be passed into func. 

81 

82 kwargs : dict, default None 

83 Keyword arguments to be passed into func.\n 

84 """ 

85).replace("\n", "", 1) 

86 

87numba_notes = ( 

88 "See :ref:`window.numba_engine` and :ref:`enhancingperf.numba` for " 

89 "extended documentation and performance considerations for the Numba engine.\n\n" 

90) 

91 

92 

93def window_agg_numba_parameters(version: str = "1.3") -> str: 

94 return ( 

95 dedent( 

96 """ 

97 engine : str, default None 

98 * ``'cython'`` : Runs the operation through C-extensions from cython. 

99 * ``'numba'`` : Runs the operation through JIT compiled code from numba. 

100 * ``None`` : Defaults to ``'cython'`` or globally setting ``compute.use_numba`` 

101 

102 .. versionadded:: {version}.0 

103 

104 engine_kwargs : dict, default None 

105 * For ``'cython'`` engine, there are no accepted ``engine_kwargs`` 

106 * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil`` 

107 and ``parallel`` dictionary keys. The values must either be ``True`` or 

108 ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is 

109 ``{{'nopython': True, 'nogil': False, 'parallel': False}}`` 

110 

111 .. versionadded:: {version}.0\n 

112 """ 

113 ) 

114 .replace("\n", "", 1) 

115 .replace("{version}", version) 

116 )