Skip to content

Commit

Permalink
remove nan example, narwhals-dev#1401
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Nov 19, 2024
1 parent 3f2a26d commit e8eb645
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 124 deletions.
32 changes: 0 additions & 32 deletions narwhals/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
30 changes: 0 additions & 30 deletions narwhals/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
62 changes: 0 additions & 62 deletions narwhals/stable/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e8eb645

Please sign in to comment.