33
44
55def ols (trendline_options , x_raw , x , y , x_label , y_label , non_missing ):
6- """Ordinary Least Squares trendline function
6+ """Ordinary Least Squares (OLS) trendline function
77
88 Requires `statsmodels` to be installed.
99
10+ This trendline function causes fit results to be stored within the figure,
11+ accessible via the `plotly.express.get_trendline_results` function. The fit results
12+ are the output of the `statsmodels.api.OLS` function.
13+
1014 Valid keys for the `trendline_options` dict are:
1115
12- `add_constant` (`bool`, default `True`): if `False`, the trendline passes through
16+ - `add_constant` (`bool`, default `True`): if `False`, the trendline passes through
1317 the origin but if `True` a y-intercept is fitted.
1418
15- `log_x` and `log_y` (`bool`, default `False`): if `True` the OLS is computed with
19+ - `log_x` and `log_y` (`bool`, default `False`): if `True` the OLS is computed with
1620 respect to the base 10 logarithm of the input. Note that this means no zeros can
1721 be present in the input.
1822 """
@@ -60,13 +64,14 @@ def ols(trendline_options, x_raw, x, y, x_label, y_label, non_missing):
6064
6165
6266def lowess (trendline_options , x_raw , x , y , x_label , y_label , non_missing ):
63- """Locally Weighted Scatterplot Smoothing trendline function
67+ """LOcally WEighted Scatterplot Smoothing (LOWESS) trendline function
6468
6569 Requires `statsmodels` to be installed.
6670
6771 Valid keys for the `trendline_options` dict are:
6872
69- `frac` (`float`, default `0.6666666`): the `frac` parameter from `statsmodels.api.nonparametric.lowess`
73+ - `frac` (`float`, default `0.6666666`): the `frac` parameter from the
74+ `statsmodels.api.nonparametric.lowess` function
7075 """
7176 import statsmodels .api as sm
7277
@@ -77,19 +82,25 @@ def lowess(trendline_options, x_raw, x, y, x_label, y_label, non_missing):
7782
7883
7984def ma (trendline_options , x_raw , x , y , x_label , y_label , non_missing ):
80- """Moving Average trendline function
85+ """Moving Average (MA) trendline function
86+
87+ Requires `pandas` to be installed.
8188
82- The `trendline_options` dict is passed as keyword arguments into the `pandas.Series.rolling` function.
89+ The `trendline_options` dict is passed as keyword arguments into the
90+ `pandas.Series.rolling` function.
8391 """
8492 y_out = pd .Series (y , index = x_raw ).rolling (** trendline_options ).mean ()[non_missing ]
8593 hover_header = "<b>MA trendline</b><br><br>"
8694 return y_out , hover_header , None
8795
8896
8997def ewma (trendline_options , x_raw , x , y , x_label , y_label , non_missing ):
90- """Exponentially Weighted Moving Average trendline function
98+ """Exponentially Weighted Moving Average (EWMA) trendline function
99+
100+ Requires `pandas` to be installed.
91101
92- The `trendline_options` dict is passed as keyword arguments into the `pandas.Series.ewma` function.
102+ The `trendline_options` dict is passed as keyword arguments into the
103+ `pandas.Series.ewma` function.
93104 """
94105 y_out = pd .Series (y , index = x_raw ).ewm (** trendline_options ).mean ()[non_missing ]
95106 hover_header = "<b>EWMA trendline</b><br><br>"
0 commit comments