Pelage: Defensive analysis for Polars
  • Get started
  • API Reference
  • Examples
  • Coming from dbt
  • Git
  1. Check functions
  2. has_no_nulls
  • API Reference
  • Check functions
    • has_columns
    • has_dtypes
    • has_no_nulls
    • has_no_infs
    • unique
    • unique_combination_of_columns
    • accepted_values
    • not_accepted_values
    • accepted_range
    • maintains_relationships
    • column_is_within_n_std
    • custom_check
  • Checks with group_by
    • has_shape
    • at_least_one
    • not_constant
    • not_null_proportion
    • has_mandatory_values
    • mutually_exclusive_ranges
    • is_monotonic
  • Exceptions
    • PolarsAssertError

On this page

  • has_no_nulls
    • Parameters
    • Returns
    • Examples
  1. Check functions
  2. has_no_nulls

has_no_nulls

checks.has_no_nulls(data, columns=None)

Check if a DataFrame has any null (missing) values.

Parameters

data: PolarsLazyOrDataFrame

The input DataFrame to check for null values.

columns: Optional[PolarsColumnType] = None

Columns to consider for null value check. By default, all columns are checked.

Returns

Type Description
PolarsLazyOrDataFrame The original polars DataFrame or LazyFrame when the check passes

Examples

>>> import polars as pl
>>> from pelage import checks
>>> df = pl.DataFrame({
...     "A": [1, 2],
...     "B": [None, 5]
... })
>>> df
shape: (2, 2)
┌─────┬──────┐
│ A   ┆ B    │
│ --- ┆ ---  │
│ i64 ┆ i64  │
╞═════╪══════╡
│ 1   ┆ null │
│ 2   ┆ 5    │
└─────┴──────┘
>>> checks.has_no_nulls(df)
Traceback (most recent call last):
    ...
pelage.checks.PolarsAssertError: Details
shape: (1, 2)
┌────────┬────────────┐
│ column ┆ null_count │
│ ---    ┆ ---        │
│ str    ┆ u32        │
╞════════╪════════════╡
│ B      ┆ 1          │
└────────┴────────────┘
Error with the DataFrame passed to the check function:
--> There were unexpected nulls in the columns above
has_dtypes
has_no_infs