Skip to content

Commit

Permalink
Convert masked arrays to valid numpy dtype
Browse files Browse the repository at this point in the history
  • Loading branch information
phofl committed Sep 3, 2023
1 parent c866a4a commit c3c718c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pandas/core/arrays/masked.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,14 @@ def to_numpy(
if na_value is lib.no_default:
na_value = libmissing.NA
if dtype is None:
dtype = object
if self._hasna:
itemsize = self.dtype.itemsize
if itemsize < 4:
itemsize = 4
dtype = np.dtype(f"f{itemsize}")
na_value = np.nan
else:
dtype = self.dtype.numpy_dtype
else:
dtype = np.dtype(dtype)
if self._hasna:
Expand Down

0 comments on commit c3c718c

Please sign in to comment.