Path: blob/main/py-polars/tests/unit/operations/test_drop_nulls.py
6939 views
from __future__ import annotations12from hypothesis import given34import polars as pl5from polars.testing import assert_frame_equal, assert_series_equal6from polars.testing.parametric import series789@given(10s=series(11allow_null=True,12excluded_dtypes=[13pl.Struct, # See: https://github.com/pola-rs/polars/issues/346214],15)16)17def test_drop_nulls_parametric(s: pl.Series) -> None:18result = s.drop_nulls()19assert result.len() == s.len() - s.null_count()2021filter_result = s.filter(s.is_not_null())22assert_series_equal(result, filter_result)232425def test_df_drop_nulls_struct() -> None:26df = pl.DataFrame(27{"x": [{"a": 1, "b": 2}, {"a": 1, "b": None}, {"a": None, "b": 2}, None]}28)2930result = df.drop_nulls()3132expected = df.head(3)33assert_frame_equal(result, expected)343536