Skip to content

DOC: explain EWM #34901

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

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
6 changes: 3 additions & 3 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10460,7 +10460,7 @@ def _add_series_or_dataframe_operations(cls):
Add the series or dataframe only operations to the cls; evaluate
the doc strings again.
"""
from pandas.core.window import EWM, Expanding, Rolling, Window
from pandas.core.window import EWF, Expanding, Rolling, Window
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would be ok with actually writing this classname out if we are going to change it, e.g. ExponentialMoving or ExponentialMovingWindow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good might as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick one could you clarify what you mean by writing it out?

Copy link
Member

@charlesdong1991 charlesdong1991 Jun 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @jreback meant you could rename EWM to ExponentialMoving or ExponentialMovingWindow in core.window.ewm.py where the class is created

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes resolved


@doc(Rolling)
def rolling(
Expand Down Expand Up @@ -10507,7 +10507,7 @@ def expanding(self, min_periods=1, center=False, axis=0):

cls.expanding = expanding

@doc(EWM)
@doc(EWF)
def ewm(
self,
com=None,
Expand All @@ -10520,7 +10520,7 @@ def ewm(
axis=0,
):
axis = self._get_axis_number(axis)
return EWM(
return EWF(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still need to change?

self,
com=com,
span=span,
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/window/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from pandas.core.window.ewm import EWM # noqa:F401
from pandas.core.window.ewf import EWF # noqa:F401
from pandas.core.window.expanding import Expanding, ExpandingGroupby # noqa:F401
from pandas.core.window.rolling import Rolling, RollingGroupby, Window # noqa:F401
8 changes: 4 additions & 4 deletions pandas/core/window/ewm.py → pandas/core/window/ewf.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ def get_center_of_mass(
return float(comass)


class EWM(_Rolling):
class Exponential_moving(_Rolling):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you use ExpontentialMoving other than Expontential_moving?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

r"""
Provide exponential weighted (EW) functions.
Provide exponential weighted Functions(EWF).

Available EW functions: ``mean()``, ``var()``, ``std()``, ``corr()``, ``cov()``.
Available functions: ``mean()``, ``var()``, ``std()``, ``corr()``, ``cov()``.

Exactly one parameter: ``com``, ``span``, ``halflife``, or ``alpha`` must be
provided.
Expand Down Expand Up @@ -185,7 +185,7 @@ def __init__(

@property
def _constructor(self):
return EWM
return EWF

_agg_see_also_doc = dedent(
"""
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/window/test_ewm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pandas.errors import UnsupportedFunctionCall

from pandas import DataFrame, Series
from pandas.core.window import EWM
from pandas.core.window import EWF


def test_doc_string():
Expand Down Expand Up @@ -56,7 +56,7 @@ def test_constructor(which):
@pytest.mark.parametrize("method", ["std", "mean", "var"])
def test_numpy_compat(method):
# see gh-12811
e = EWM(Series([2, 4, 6]), alpha=0.5)
e = EWF(Series([2, 4, 6]), alpha=0.5)

msg = "numpy operations are not valid with window objects"

Expand Down