Skip to content

BUG: Creation of UInt64 column with 18446744073709551615 throws RuntimeWarning #60214

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

Closed
wants to merge 18 commits into from
Closed
Changes from 1 commit
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
12 changes: 9 additions & 3 deletions pandas/core/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
maybe_cast_to_integer_array,
maybe_convert_platform,
maybe_infer_to_datetimelike,
maybe_promote,
)
from pandas.core.dtypes.common import (
ensure_object,
Expand Down Expand Up @@ -513,10 +512,17 @@ def sanitize_masked_array(data: ma.MaskedArray) -> np.ndarray:
"""
mask = ma.getmaskarray(data)
if mask.any():
dtype, fill_value = maybe_promote(data.dtype, np.nan)
dtype = cast(np.dtype, dtype)
dtype = cast(np.dtype, data.dtype)
data = ma.asarray(data.astype(dtype, copy=True))
data.soften_mask() # set hardmask False if it was True

if np.issubdtype(dtype, np.integer):
fill_value: int | float | None = np.iinfo(dtype).min
elif np.issubdtype(dtype, np.floating):
fill_value = np.nan
else:
fill_value = None

data[mask] = fill_value
else:
data = data.copy()
Expand Down
Loading