From d3dd4d3cc98d5b937e053cdbe3c7ed1f0bce24b9 Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 2 Feb 2021 16:14:59 -0800 Subject: [PATCH] CLN: re-use na_value_for_dtype --- pandas/core/algorithms.py | 15 ++------------- pandas/core/nanops.py | 2 -- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index e55ddbcc783d0..2b0d3f5aa8862 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -1660,18 +1660,6 @@ def take(arr, indices, axis: int = 0, allow_fill: bool = False, fill_value=None) return result -# TODO: can we de-duplicate with something in dtypes.missing? -def _get_default_fill_value(dtype, fill_value): - if fill_value is lib.no_default: - if is_extension_array_dtype(dtype): - fill_value = dtype.na_value - elif dtype.kind in ["m", "M"]: - fill_value = dtype.type("NaT") - else: - fill_value = np.nan - return fill_value - - def take_nd( arr, indexer, @@ -1713,7 +1701,8 @@ def take_nd( """ mask_info = None - fill_value = _get_default_fill_value(arr.dtype, fill_value) + if fill_value is lib.no_default: + fill_value = na_value_for_dtype(arr.dtype, compat=False) if isinstance(arr, ABCExtensionArray): # Check for EA to catch DatetimeArray, TimedeltaArray diff --git a/pandas/core/nanops.py b/pandas/core/nanops.py index 8d3363df0d132..4af1084033ce2 100644 --- a/pandas/core/nanops.py +++ b/pandas/core/nanops.py @@ -417,8 +417,6 @@ def _na_for_min_count( if is_numeric_dtype(values): values = values.astype("float64") fill_value = na_value_for_dtype(values.dtype) - if fill_value is NaT: - fill_value = values.dtype.type("NaT", "ns") if values.ndim == 1: return fill_value