itholic commented on code in PR #36063:
URL: https://github.com/apache/spark/pull/36063#discussion_r846953442
##########
python/pyspark/pandas/generic.py:
##########
@@ -2619,6 +2619,56 @@ def expanding(self: FrameLike, min_periods: int = 1) ->
"Expanding[FrameLike]":
return Expanding(self, min_periods=min_periods)
+ # TODO: 'adjust', 'ignore_na', 'axis', 'method' parameter should be
implemented.
+ def ewm(
+ self: FrameLike,
+ com: Optional[float] = None,
+ span: Optional[float] = None,
+ halflife: Optional[float] = None,
+ alpha: Optional[float] = None,
+ min_periods: Optional[int] = None,
+ ) -> "ExponentialMoving[FrameLike]":
+ """
+ Provide exponentially weighted window transformations.
+
+ .. note:: 'min_periods' in pandas-on-Spark works as a fixed window
size unlike pandas.
+ Unlike pandas, NA is also counted as the period. This might be
changed
+ in the near future.
+
+ .. versionadded:: 3.4.0
+
+ Parameters
+ ----------
+ com : float, optional
+ Specify decay in terms of center of mass.
+ alpha = 1 / (1 + com), for com >= 0.
+
+ span : float, optional
+ Specify decay in terms of span.
+ alpha = 2 / (span + 1), for span >= 1.
+
+ halflife : float, optional
+ Specify decay in terms of half-life.
+ alpha = 1 - exp(-ln(2) / halflife), for halflife > 0.
+
+ alpha : float, optional
+ Specify smoothing factor alpha directly.
+ 0 < alpha <= 1.
+
+ min_periods : int, default 0
+ Minimum number of observations in window required to have a value
+ (otherwise result is NA).
Review Comment:
It's not copied pandas but copied from:
https://github.com/apache/spark/blob/2f122ba6d13ea26411fa4bf3e636ced449a8a205/python/pyspark/pandas/generic.py#L2584-L2586
and:
https://github.com/apache/spark/blob/2f122ba6d13ea26411fa4bf3e636ced449a8a205/python/pyspark/pandas/generic.py#L2610-L2612
In our code base.
pandas says "otherwise, result is `np.nan`." as beolw:
<img width="633" alt="Screen Shot 2022-04-11 at 2 15 34 PM"
src="https://user-images.githubusercontent.com/44108233/162669417-3fb30a27-8d29-45af-9af5-06681a24ff86.png">
Maybe we should document as `np.nan` and also fix the document at `rolling`
and `expanding` ??
##########
python/pyspark/pandas/generic.py:
##########
@@ -2619,6 +2619,56 @@ def expanding(self: FrameLike, min_periods: int = 1) ->
"Expanding[FrameLike]":
return Expanding(self, min_periods=min_periods)
+ # TODO: 'adjust', 'ignore_na', 'axis', 'method' parameter should be
implemented.
+ def ewm(
+ self: FrameLike,
+ com: Optional[float] = None,
+ span: Optional[float] = None,
+ halflife: Optional[float] = None,
+ alpha: Optional[float] = None,
+ min_periods: Optional[int] = None,
+ ) -> "ExponentialMoving[FrameLike]":
+ """
+ Provide exponentially weighted window transformations.
+
+ .. note:: 'min_periods' in pandas-on-Spark works as a fixed window
size unlike pandas.
+ Unlike pandas, NA is also counted as the period. This might be
changed
+ in the near future.
+
+ .. versionadded:: 3.4.0
+
+ Parameters
+ ----------
+ com : float, optional
+ Specify decay in terms of center of mass.
+ alpha = 1 / (1 + com), for com >= 0.
+
+ span : float, optional
+ Specify decay in terms of span.
+ alpha = 2 / (span + 1), for span >= 1.
+
+ halflife : float, optional
+ Specify decay in terms of half-life.
+ alpha = 1 - exp(-ln(2) / halflife), for halflife > 0.
+
+ alpha : float, optional
+ Specify smoothing factor alpha directly.
+ 0 < alpha <= 1.
+
+ min_periods : int, default 0
+ Minimum number of observations in window required to have a value
+ (otherwise result is NA).
Review Comment:
It's not copied from pandas but copied from:
https://github.com/apache/spark/blob/2f122ba6d13ea26411fa4bf3e636ced449a8a205/python/pyspark/pandas/generic.py#L2584-L2586
and:
https://github.com/apache/spark/blob/2f122ba6d13ea26411fa4bf3e636ced449a8a205/python/pyspark/pandas/generic.py#L2610-L2612
In our code base.
pandas says "otherwise, result is `np.nan`." as beolw:
<img width="633" alt="Screen Shot 2022-04-11 at 2 15 34 PM"
src="https://user-images.githubusercontent.com/44108233/162669417-3fb30a27-8d29-45af-9af5-06681a24ff86.png">
Maybe we should document as `np.nan` and also fix the document at `rolling`
and `expanding` ??
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]