-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from narwhals-dev/fill-null
fill_null
- Loading branch information
Showing
7 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
- cast | ||
- diff | ||
- drop_nulls | ||
- fill_null | ||
- filter | ||
- is_between | ||
- is_in | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
- diff | ||
- drop_nulls | ||
- dtype | ||
- fill_null | ||
- filter | ||
- is_between | ||
- is_in | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from typing import Any | ||
|
||
import pandas as pd | ||
import polars as pl | ||
import pytest | ||
|
||
import narwhals as nw | ||
from tests.utils import compare_dicts | ||
|
||
data = { | ||
"a": [0.0, None, 2, 3, 4], | ||
"b": [1.0, None, None, 5, 3], | ||
"c": [5.0, None, 3, 2, 1], | ||
} | ||
|
||
|
||
@pytest.mark.parametrize("constructor", [pd.DataFrame, pl.DataFrame]) | ||
def test_over_single(constructor: Any) -> None: | ||
df = nw.from_native(constructor(data), eager_only=True) | ||
result = df.with_columns(nw.all().fill_null(99)) | ||
expected = { | ||
"a": [0.0, 99, 2, 3, 4], | ||
"b": [1.0, 99, 99, 5, 3], | ||
"c": [5.0, 99, 3, 2, 1], | ||
} | ||
compare_dicts(result, expected) | ||
result = df.with_columns( | ||
a=df["a"].fill_null(99), | ||
b=df["b"].fill_null(99), | ||
c=df["c"].fill_null(99), | ||
) | ||
compare_dicts(result, expected) |