24 lines
631 B
Python
24 lines
631 B
Python
"""Reglas de documento (homologación; split se aplica en apply.py)."""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
import pandas as pd
|
|
|
|
from ..documents import homologate_doc_type, split_doc_tipo_y_numero_texto
|
|
from ..nullish import _is_nullish_scalar
|
|
|
|
|
|
def _rule_doc_type_homologate(series: pd.Series) -> pd.Series:
|
|
"""Homologa una columna que contiene tipos de documento."""
|
|
|
|
def _fn(x: Any):
|
|
if _is_nullish_scalar(x):
|
|
return x
|
|
tipo, _num = split_doc_tipo_y_numero_texto(x, homologate=True)
|
|
if tipo is not None:
|
|
return tipo
|
|
return homologate_doc_type(x)
|
|
|
|
return series.map(_fn)
|