diff --git a/narwhals/expr.py b/narwhals/expr.py index ea7271984..ddacd4fff 100644 --- a/narwhals/expr.py +++ b/narwhals/expr.py @@ -459,7 +459,6 @@ def ewm_mean( calculating the final weighted average of $[x_0, None, x_2]$ are $(1-\alpha)^2$ and $1$ if `adjust=True`, and $(1-\alpha)^2$ and $\alpha$ if `adjust=False`. - - When `ignore_nulls=True`, weights are based on relative positions. For example, the weights of $x_0$ and $x_2$ used in calculating the final weighted @@ -503,37 +502,6 @@ def ewm_mean( │ 1.666667 │ │ 2.428571 │ └──────────┘ - - pandas and Polars handle nulls differently. So, calculating ewm over - a sequence with null values leads to distinct results: - - >>> data = {"a": [2.0, 4.0, None, 3.0, float("nan"), 3.0]} - >>> df_pd2 = pd.DataFrame(data) - >>> df_pl2 = pl.DataFrame(data) - - >>> func(df_pd2) - a - 0 2.000000 - 1 3.333333 - 2 NaN - 3 3.090909 - 4 NaN - 5 3.023256 - - >>> func(df_pl2) # doctest: +NORMALIZE_WHITESPACE - shape: (6, 1) - ┌──────────┐ - │ a │ - │ --- │ - │ f64 │ - ╞══════════╡ - │ 2.0 │ - │ 3.333333 │ - │ null │ - │ 3.090909 │ - │ NaN │ - │ NaN │ - └──────────┘ """ return self.__class__( lambda plx: self._call(plx).ewm_mean( diff --git a/narwhals/series.py b/narwhals/series.py index 7e60b1581..01829cb04 100644 --- a/narwhals/series.py +++ b/narwhals/series.py @@ -418,7 +418,6 @@ def ewm_mean( calculating the final weighted average of $[x_0, None, x_2]$ are $(1-\alpha)^2$ and $1$ if `adjust=True`, and $(1-\alpha)^2$ and $\alpha$ if `adjust=False`. - - When `ignore_nulls=True`, weights are based on relative positions. For example, the weights of $x_0$ and $x_2$ used in calculating the final weighted @@ -459,35 +458,6 @@ def ewm_mean( 1.666667 2.428571 ] - - pandas and Polars handle NaN differently. So, calculating ewm over - a sequence with null values leads to distinct results. Narwhals - matches Polars' results when "None" is in the input. - - >>> data = [2.0, 4.0, None, 3.0, float("nan"), 3.0] - >>> s_pd2 = pd.Series(name="a", data=data) - >>> s_pl2 = pl.Series(name="a", values=data) - - >>> func(s_pd2) - 0 2.000000 - 1 3.333333 - 2 NaN - 3 3.090909 - 4 NaN - 5 3.023256 - Name: a, dtype: float64 - - >>> func(s_pl2) # doctest: +NORMALIZE_WHITESPACE - shape: (6,) - Series: 'a' [f64] - [ - 2.0 - 3.333333 - null - 3.090909 - NaN - NaN - ] """ return self._from_compliant_series( self._compliant_series.ewm_mean( diff --git a/narwhals/stable/v1/__init__.py b/narwhals/stable/v1/__init__.py index 174115813..12016d80d 100644 --- a/narwhals/stable/v1/__init__.py +++ b/narwhals/stable/v1/__init__.py @@ -535,7 +535,6 @@ def ewm_mean( calculating the final weighted average of $[x_0, None, x_2]$ are $(1-\alpha)^2$ and $1$ if `adjust=True`, and $(1-\alpha)^2$ and $\alpha$ if `adjust=False`. - - When `ignore_nulls=True`, weights are based on relative positions. For example, the weights of $x_0$ and $x_2$ used in calculating the final weighted @@ -576,35 +575,6 @@ def ewm_mean( 1.666667 2.428571 ] - - pandas and Polars handle NaN differently. So, calculating ewm over - a sequence with null values leads to distinct results. Narwhals - matches Polars' results when "None" is in the input. - - >>> data = [2.0, 4.0, None, 3.0, float("nan"), 3.0] - >>> s_pd2 = pd.Series(name="a", data=data) - >>> s_pl2 = pl.Series(name="a", values=data) - - >>> func(s_pd2) - 0 2.000000 - 1 3.333333 - 2 NaN - 3 3.090909 - 4 NaN - 5 3.023256 - Name: a, dtype: float64 - - >>> func(s_pl2) # doctest: +NORMALIZE_WHITESPACE - shape: (6,) - Series: 'a' [f64] - [ - 2.0 - 3.333333 - null - 3.090909 - NaN - NaN - ] """ from narwhals.exceptions import NarwhalsUnstableWarning from narwhals.utils import find_stacklevel @@ -762,7 +732,6 @@ def ewm_mean( calculating the final weighted average of $[x_0, None, x_2]$ are $(1-\alpha)^2$ and $1$ if `adjust=True`, and $(1-\alpha)^2$ and $\alpha$ if `adjust=False`. - - When `ignore_nulls=True`, weights are based on relative positions. For example, the weights of $x_0$ and $x_2$ used in calculating the final weighted @@ -806,37 +775,6 @@ def ewm_mean( │ 1.666667 │ │ 2.428571 │ └──────────┘ - - pandas and Polars handle nulls differently. So, calculating ewm over - a sequence with null values leads to distinct results: - - >>> data = {"a": [2.0, 4.0, None, 3.0, float("nan"), 3.0]} - >>> df_pd2 = pd.DataFrame(data) - >>> df_pl2 = pl.DataFrame(data) - - >>> func(df_pd2) - a - 0 2.000000 - 1 3.333333 - 2 NaN - 3 3.090909 - 4 NaN - 5 3.023256 - - >>> func(df_pl2) # doctest: +NORMALIZE_WHITESPACE - shape: (6, 1) - ┌──────────┐ - │ a │ - │ --- │ - │ f64 │ - ╞══════════╡ - │ 2.0 │ - │ 3.333333 │ - │ null │ - │ 3.090909 │ - │ NaN │ - │ NaN │ - └──────────┘ """ from narwhals.exceptions import NarwhalsUnstableWarning from narwhals.utils import find_stacklevel