From fb5eac01beef3b60f526d02d608175779604b899 Mon Sep 17 00:00:00 2001 From: KrishnaSai2020 Date: Sat, 20 Jun 2020 14:20:51 +0100 Subject: [PATCH 1/9] Fixed docs issue #34867 --- pandas/core/generic.py | 6 +++--- pandas/core/window/__init__.py | 2 +- pandas/core/window/{ewm.py => ewf.py} | 8 ++++---- pandas/tests/window/test_ewm.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) rename pandas/core/window/{ewm.py => ewf.py} (98%) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 701909c9df857..c903a8ec09f0d 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -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 @doc(Rolling) def rolling( @@ -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, @@ -10520,7 +10520,7 @@ def ewm( axis=0, ): axis = self._get_axis_number(axis) - return EWM( + return EWF( self, com=com, span=span, diff --git a/pandas/core/window/__init__.py b/pandas/core/window/__init__.py index dcf58a4c0dd5b..a0adada983e6b 100644 --- a/pandas/core/window/__init__.py +++ b/pandas/core/window/__init__.py @@ -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 diff --git a/pandas/core/window/ewm.py b/pandas/core/window/ewf.py similarity index 98% rename from pandas/core/window/ewm.py rename to pandas/core/window/ewf.py index b708020be90d2..632c29ff7dfc7 100644 --- a/pandas/core/window/ewm.py +++ b/pandas/core/window/ewf.py @@ -59,11 +59,11 @@ def get_center_of_mass( return float(comass) -class EWM(_Rolling): +class EWF(_Rolling): r""" - Provide exponential weighted (EW) functions. + Provide exponential weighted Functions(EWF). - Available EW functions: ``mean()``, ``var()``, ``std()``, ``corr()``, ``cov()``. + Available Exponential Weighted functions: ``mean()``, ``var()``, ``std()``, ``corr()``, ``cov()``. Exactly one parameter: ``com``, ``span``, ``halflife``, or ``alpha`` must be provided. @@ -185,7 +185,7 @@ def __init__( @property def _constructor(self): - return EWM + return EWF _agg_see_also_doc = dedent( """ diff --git a/pandas/tests/window/test_ewm.py b/pandas/tests/window/test_ewm.py index 9ba194dcf0959..019791c7e033d 100644 --- a/pandas/tests/window/test_ewm.py +++ b/pandas/tests/window/test_ewm.py @@ -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(): @@ -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" From c165fc34151ea43318d8a0d871246b8fc93ce001 Mon Sep 17 00:00:00 2001 From: Krishna Chivukula <63070026+KrishnaSai2020@users.noreply.github.com> Date: Sat, 20 Jun 2020 14:36:46 +0100 Subject: [PATCH 2/9] fix pep 8 issues reduced line length --- pandas/core/window/ewf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/window/ewf.py b/pandas/core/window/ewf.py index 632c29ff7dfc7..6494f7c243948 100644 --- a/pandas/core/window/ewf.py +++ b/pandas/core/window/ewf.py @@ -63,7 +63,7 @@ class EWF(_Rolling): r""" Provide exponential weighted Functions(EWF). - Available Exponential Weighted functions: ``mean()``, ``var()``, ``std()``, ``corr()``, ``cov()``. + Available functions: ``mean()``, ``var()``, ``std()``, ``corr()``, ``cov()``. Exactly one parameter: ``com``, ``span``, ``halflife``, or ``alpha`` must be provided. From 2e0386cfd0791595a7764a3b6b9e0853986eaf6e Mon Sep 17 00:00:00 2001 From: Krishna Chivukula <63070026+KrishnaSai2020@users.noreply.github.com> Date: Sat, 20 Jun 2020 14:52:02 +0100 Subject: [PATCH 3/9] update ewf.py --- pandas/core/window/ewf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/window/ewf.py b/pandas/core/window/ewf.py index 6494f7c243948..51db29af80003 100644 --- a/pandas/core/window/ewf.py +++ b/pandas/core/window/ewf.py @@ -59,7 +59,7 @@ def get_center_of_mass( return float(comass) -class EWF(_Rolling): +class Exponential_moving(_Rolling): r""" Provide exponential weighted Functions(EWF). From e726629f0ee7d25d6c0210061486b5d1458e02b2 Mon Sep 17 00:00:00 2001 From: Krishna Chivukula <63070026+KrishnaSai2020@users.noreply.github.com> Date: Sat, 20 Jun 2020 14:54:30 +0100 Subject: [PATCH 4/9] refactoring name to exponential moving --- pandas/tests/window/{test_ewm.py => test_ewf.py} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename pandas/tests/window/{test_ewm.py => test_ewf.py} (93%) diff --git a/pandas/tests/window/test_ewm.py b/pandas/tests/window/test_ewf.py similarity index 93% rename from pandas/tests/window/test_ewm.py rename to pandas/tests/window/test_ewf.py index 019791c7e033d..a4e5f43f8145a 100644 --- a/pandas/tests/window/test_ewm.py +++ b/pandas/tests/window/test_ewf.py @@ -4,7 +4,7 @@ from pandas.errors import UnsupportedFunctionCall from pandas import DataFrame, Series -from pandas.core.window import EWF +from pandas.core.window import Exponential_moving as em def test_doc_string(): @@ -56,7 +56,7 @@ def test_constructor(which): @pytest.mark.parametrize("method", ["std", "mean", "var"]) def test_numpy_compat(method): # see gh-12811 - e = EWF(Series([2, 4, 6]), alpha=0.5) + e = em(Series([2, 4, 6]), alpha=0.5) msg = "numpy operations are not valid with window objects" From f95216c54719012d8201988b1d07b3820b29920e Mon Sep 17 00:00:00 2001 From: Krishna Chivukula <63070026+KrishnaSai2020@users.noreply.github.com> Date: Sat, 20 Jun 2020 14:57:07 +0100 Subject: [PATCH 5/9] update ewf.py --- pandas/core/window/ewf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/window/ewf.py b/pandas/core/window/ewf.py index 51db29af80003..928dfb5dc16ff 100644 --- a/pandas/core/window/ewf.py +++ b/pandas/core/window/ewf.py @@ -59,7 +59,7 @@ def get_center_of_mass( return float(comass) -class Exponential_moving(_Rolling): +class Exponentialmoving(_Rolling): r""" Provide exponential weighted Functions(EWF). From d4343e3d4e6fa5b8283ac168f77b4be0f01d3551 Mon Sep 17 00:00:00 2001 From: Krishna Chivukula <63070026+KrishnaSai2020@users.noreply.github.com> Date: Sat, 20 Jun 2020 14:57:40 +0100 Subject: [PATCH 6/9] renamed class --- pandas/tests/window/test_ewf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/window/test_ewf.py b/pandas/tests/window/test_ewf.py index a4e5f43f8145a..ae0f1bc47cf81 100644 --- a/pandas/tests/window/test_ewf.py +++ b/pandas/tests/window/test_ewf.py @@ -4,7 +4,7 @@ from pandas.errors import UnsupportedFunctionCall from pandas import DataFrame, Series -from pandas.core.window import Exponential_moving as em +from pandas.core.window import Exponentialmoving as em def test_doc_string(): From 38ca722e29cac0bb778a0095ba36eef3607b3e6d Mon Sep 17 00:00:00 2001 From: Krishna Chivukula <63070026+KrishnaSai2020@users.noreply.github.com> Date: Sat, 20 Jun 2020 14:59:20 +0100 Subject: [PATCH 7/9] renamed file --- pandas/core/window/{ewf.py => exponentialmoving.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pandas/core/window/{ewf.py => exponentialmoving.py} (100%) diff --git a/pandas/core/window/ewf.py b/pandas/core/window/exponentialmoving.py similarity index 100% rename from pandas/core/window/ewf.py rename to pandas/core/window/exponentialmoving.py From b10bc720e41171844c23695c4a73fc35b1d8b353 Mon Sep 17 00:00:00 2001 From: Krishna Chivukula <63070026+KrishnaSai2020@users.noreply.github.com> Date: Sat, 20 Jun 2020 15:00:35 +0100 Subject: [PATCH 8/9] updated init.py --- pandas/core/window/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/window/__init__.py b/pandas/core/window/__init__.py index a0adada983e6b..d3e78f779fae8 100644 --- a/pandas/core/window/__init__.py +++ b/pandas/core/window/__init__.py @@ -1,3 +1,3 @@ -from pandas.core.window.ewf import EWF # noqa:F401 +from pandas.core.window.ewf import exponentialmoving # noqa:F401 from pandas.core.window.expanding import Expanding, ExpandingGroupby # noqa:F401 from pandas.core.window.rolling import Rolling, RollingGroupby, Window # noqa:F401 From 61f316b4234860f4031850a73187e1b96c1a28c0 Mon Sep 17 00:00:00 2001 From: Krishna Chivukula <63070026+KrishnaSai2020@users.noreply.github.com> Date: Sat, 20 Jun 2020 15:03:43 +0100 Subject: [PATCH 9/9] update generic.py --- pandas/core/generic.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index c903a8ec09f0d..ee2a7454d261e 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10460,7 +10460,8 @@ 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 EWF, Expanding, Rolling, Window + from pandas.core.window import exponentialmoving as em + from pandas.core.window import Expanding, Rolling, Window @doc(Rolling) def rolling( @@ -10507,7 +10508,7 @@ def expanding(self, min_periods=1, center=False, axis=0): cls.expanding = expanding - @doc(EWF) + @doc(em) def ewm( self, com=None, @@ -10532,7 +10533,7 @@ def ewm( axis=axis, ) - cls.ewm = ewm + cls.eem = em @doc(klass=_shared_doc_kwargs["klass"], axis="") def transform(self, func, *args, **kwargs):