Skip to content

Commit f301506

Browse files
committed
try to fix rest
1 parent fd2ba65 commit f301506

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

pandas/core/arrays/numpy_.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,12 +516,15 @@ def to_numpy(
516516
# to_numpy on StringArray backed by StringDType should still return object dtype
517517
# for backwards compat
518518
array = self._ndarray
519-
if dtype is None and self._ndarray.dtype.kind == "T":
520-
dtype = object
521-
result = np.asarray(array, dtype=dtype)
519+
if self._ndarray.dtype.kind == "T":
520+
array = array.astype(object)
522521
if na_value is not lib.no_default and mask.any():
523-
result = result.copy()
522+
result = array.copy()
524523
result[mask] = na_value
524+
else:
525+
result = self._ndarray
526+
527+
result = np.asarray(result, dtype=dtype)
525528

526529
if copy and result is self._ndarray:
527530
result = result.copy()

pandas/core/nanops.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
NaTType,
1919
iNaT,
2020
lib,
21-
missing as libmissing,
2221
)
2322
from pandas._typing import (
2423
ArrayLike,
@@ -32,7 +31,6 @@
3231
npt,
3332
)
3433
from pandas.compat._optional import import_optional_dependency
35-
from pandas.compat.numpy import np_version_gt2
3634

3735
from pandas.core.dtypes.common import (
3836
is_complex,
@@ -153,12 +151,8 @@ def f(
153151

154152

155153
def _bn_ok_dtype(dtype: DtypeObj, name: str) -> bool:
156-
# Bottleneck chokes on datetime64, PeriodDtype (or and EA)
157-
if (
158-
dtype != object
159-
and (np_version_gt2 and dtype != np.dtypes.StringDType(na_object=libmissing.NA))
160-
and not needs_i8_conversion(dtype)
161-
):
154+
# Bottleneck chokes on datetime64, numpy strins, PeriodDtype (or and EA)
155+
if dtype != object and dtype.kind != "T" and not needs_i8_conversion(dtype):
162156
# GH 42878
163157
# Bottleneck uses naive summation leading to O(n) loss of precision
164158
# unlike numpy which implements pairwise summation, which has O(log(n)) loss

0 commit comments

Comments
 (0)