-
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.
- Loading branch information
1 parent
61906a0
commit d11e156
Showing
1 changed file
with
32 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 |
---|---|---|
@@ -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) |