We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3c3589b commit 6c801a6Copy full SHA for 6c801a6
pandas/core/arrays/numpy_.py
@@ -355,13 +355,19 @@ def to_numpy( # type: ignore[override]
355
copy: bool = False,
356
na_value=lib.no_default,
357
) -> np.ndarray:
358
- result = np.asarray(self._ndarray, dtype=dtype)
359
360
- if (copy or na_value is not lib.no_default) and result is self._ndarray:
361
- result = result.copy()
+ temp = self
362
363
if na_value is not lib.no_default:
364
- result[self.isna()] = na_value
+ temp = self.fillna(None)
+
365
366
+ result = np.asarray(temp._ndarray, dtype=dtype)
367
368
+ if (copy or na_value is not lib.no_default) and result is temp._ndarray:
369
+ result = result.copy()
370
371
372
return result
373
0 commit comments