This commit is contained in:
2025-09-07 22:09:54 +02:00
parent e1b817252c
commit 2fc0d000b6
7796 changed files with 2159515 additions and 933 deletions

View File

@ -0,0 +1,23 @@
import numpy as np
import pandas as pd
def is_object_or_nan_string_dtype(dtype):
"""
Check if string-like dtype is following NaN semantics, i.e. is object
dtype or a NaN-variant of the StringDtype.
"""
return (isinstance(dtype, np.dtype) and dtype == "object") or (
dtype.na_value is np.nan
)
def _convert_na_value(ser, expected):
if ser.dtype != object:
if ser.dtype.na_value is np.nan:
expected = expected.fillna(np.nan)
else:
# GH#18463
expected = expected.fillna(pd.NA)
return expected