Skip to content

CLN: re-use na_value_for_dtype #39571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions pandas/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down