25 lines
609 B
Python
25 lines
609 B
Python
"""Detección de valores nulos / vacíos."""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
import numpy as np
|
|
import pandas as pd
|
|
|
|
|
|
def _is_nullish_scalar(x: Any) -> bool:
|
|
if x is None or x is pd.NA:
|
|
return True
|
|
if isinstance(x, (bool, np.bool_)):
|
|
return False
|
|
if isinstance(x, (int, float, np.integer, np.floating)) and not isinstance(
|
|
x, (bool, np.bool_)
|
|
):
|
|
if isinstance(x, float) and (np.isnan(x) or pd.isna(x)):
|
|
return True
|
|
return False
|
|
t = str(x).strip().lower()
|
|
if not t or t in ("nan", "none", "nat", "null", "<na>"):
|
|
return True
|
|
return False
|