File tree 3 files changed +6
-16
lines changed
3 files changed +6
-16
lines changed Original file line number Diff line number Diff line change @@ -1078,7 +1078,7 @@ Performance improvements
1078
1078
- Performance improvement in :meth: `~arrays.ArrowExtensionArray.factorize ` (:issue: `49177 `)
1079
1079
- Performance improvement in :meth: `~arrays.ArrowExtensionArray.__setitem__ ` (:issue: `50248 `, :issue: `50632 `)
1080
1080
- Performance improvement in :class: `~arrays.ArrowExtensionArray ` comparison methods when array contains NA (:issue: `50524 `)
1081
- - Performance improvement in :meth: `~arrays.ArrowExtensionArray.to_numpy ` (:issue: `49973 `, :issue: ` 51227 ` )
1081
+ - Performance improvement in :meth: `~arrays.ArrowExtensionArray.to_numpy ` (:issue: `49973 `)
1082
1082
- Performance improvement when parsing strings to :class: `BooleanDtype ` (:issue: `50613 `)
1083
1083
- Performance improvement in :meth: `DataFrame.join ` when joining on a subset of a :class: `MultiIndex ` (:issue: `48611 `)
1084
1084
- Performance improvement for :meth: `MultiIndex.intersection ` (:issue: `48604 `)
Original file line number Diff line number Diff line change @@ -853,12 +853,12 @@ def to_numpy(
853
853
na_value = self .dtype .na_value
854
854
855
855
pa_type = self ._data .type
856
- if pa .types .is_timestamp (pa_type ) or pa .types .is_duration (pa_type ):
856
+ if (
857
+ is_object_dtype (dtype )
858
+ or pa .types .is_timestamp (pa_type )
859
+ or pa .types .is_duration (pa_type )
860
+ ):
857
861
result = np .array (list (self ), dtype = dtype )
858
- elif is_object_dtype (dtype ) and self ._hasna :
859
- result = np .empty (len (self ), dtype = object )
860
- mask = ~ self .isna ()
861
- result [mask ] = np .asarray (self [mask ]._data )
862
862
else :
863
863
result = np .asarray (self ._data , dtype = dtype )
864
864
if copy or self ._hasna :
Original file line number Diff line number Diff line change @@ -1518,16 +1518,6 @@ def test_to_numpy_with_defaults(data):
1518
1518
tm .assert_numpy_array_equal (result , expected )
1519
1519
1520
1520
1521
- def test_to_numpy_int_with_na ():
1522
- # GH51227: ensure to_numpy does not convert int to float
1523
- data = [1 , None ]
1524
- arr = pd .array (data , dtype = "int64[pyarrow]" )
1525
- result = arr .to_numpy ()
1526
- expected = np .array ([1 , pd .NA ], dtype = object )
1527
- assert isinstance (result [0 ], int )
1528
- tm .assert_numpy_array_equal (result , expected )
1529
-
1530
-
1531
1521
def test_setitem_null_slice (data ):
1532
1522
# GH50248
1533
1523
orig = data .copy ()
You can’t perform that action at this time.
0 commit comments