from typing import Any

import pandas as pd


def pandas_cell_to_str(v: Any) -> str:
    if v is None or (isinstance(v, float) and pd.isna(v)):
        return ""
    s = str(v).replace("\xa0", " ")
    # get_uprn_candidates runs .astype(str) on UPRN, turning NaN into "nan".
    # Treat that as missing so unambiguous_uprn truthiness checks work.
    if s.lower() == "nan":
        return ""
    return s
