Skip to content

Commit

Permalink
test files
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed May 8, 2024
1 parent 61906a0 commit d11e156
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/expr/fill_null_test.py
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)

0 comments on commit d11e156

Please sign in to comment.