Skip to content

Commit 8e2e98b

Browse files
authored
CLN: re-use na_value_for_dtype (#39571)
1 parent facdb89 commit 8e2e98b

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

pandas/core/algorithms.py

+2-13
Original file line numberDiff line numberDiff line change
@@ -1660,18 +1660,6 @@ def take(arr, indices, axis: int = 0, allow_fill: bool = False, fill_value=None)
16601660
return result
16611661

16621662

1663-
# TODO: can we de-duplicate with something in dtypes.missing?
1664-
def _get_default_fill_value(dtype, fill_value):
1665-
if fill_value is lib.no_default:
1666-
if is_extension_array_dtype(dtype):
1667-
fill_value = dtype.na_value
1668-
elif dtype.kind in ["m", "M"]:
1669-
fill_value = dtype.type("NaT")
1670-
else:
1671-
fill_value = np.nan
1672-
return fill_value
1673-
1674-
16751663
def take_nd(
16761664
arr,
16771665
indexer,
@@ -1713,7 +1701,8 @@ def take_nd(
17131701
"""
17141702
mask_info = None
17151703

1716-
fill_value = _get_default_fill_value(arr.dtype, fill_value)
1704+
if fill_value is lib.no_default:
1705+
fill_value = na_value_for_dtype(arr.dtype, compat=False)
17171706

17181707
if isinstance(arr, ABCExtensionArray):
17191708
# Check for EA to catch DatetimeArray, TimedeltaArray

pandas/core/nanops.py

-2
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,6 @@ def _na_for_min_count(
417417
if is_numeric_dtype(values):
418418
values = values.astype("float64")
419419
fill_value = na_value_for_dtype(values.dtype)
420-
if fill_value is NaT:
421-
fill_value = values.dtype.type("NaT", "ns")
422420

423421
if values.ndim == 1:
424422
return fill_value

0 commit comments

Comments
 (0)