File tree 2 files changed +26
-7
lines changed
2 files changed +26
-7
lines changed Original file line number Diff line number Diff line change 9
9
from pandas ._typing import Axis , FrameOrSeriesUnion
10
10
from pandas .util ._decorators import cache_readonly
11
11
12
- from pandas .core .dtypes .common import is_dict_like , is_list_like , is_sequence
12
+ from pandas .core .dtypes .common import (
13
+ is_dict_like ,
14
+ is_extension_array_dtype ,
15
+ is_list_like ,
16
+ is_sequence ,
17
+ )
13
18
from pandas .core .dtypes .generic import ABCSeries
14
19
15
20
from pandas .core .construction import create_series_with_explicit_dtype
@@ -392,12 +397,20 @@ def series_generator(self):
392
397
mgr = ser ._mgr
393
398
blk = mgr .blocks [0 ]
394
399
395
- for (arr , name ) in zip (values , self .index ):
396
- # GH#35462 re-pin mgr in case setitem changed it
397
- ser ._mgr = mgr
398
- blk .values = arr
399
- ser .name = name
400
- yield ser
400
+ if is_extension_array_dtype (blk .dtype ):
401
+ # values will be incorrect for this block
402
+ # TODO(EA2D): special case would be unnecessary with 2D EAs
403
+ obj = self .obj
404
+ for i in range (len (obj )):
405
+ yield obj ._ixs (i , axis = 0 )
406
+
407
+ else :
408
+ for (arr , name ) in zip (values , self .index ):
409
+ # GH#35462 re-pin mgr in case setitem changed it
410
+ ser ._mgr = mgr
411
+ blk .values = arr
412
+ ser .name = name
413
+ yield ser
401
414
402
415
@property
403
416
def result_index (self ) -> "Index" :
Original file line number Diff line number Diff line change @@ -58,6 +58,12 @@ def test_apply(self, float_frame):
58
58
assert isinstance (df ["c0" ].dtype , CategoricalDtype )
59
59
assert isinstance (df ["c1" ].dtype , CategoricalDtype )
60
60
61
+ def test_apply_axis1_with_ea (self ):
62
+ # GH#36785
63
+ df = DataFrame ({"A" : [Timestamp ("2013-01-01" , tz = "UTC" )]})
64
+ result = df .apply (lambda x : x , axis = 1 )
65
+ tm .assert_frame_equal (result , df )
66
+
61
67
def test_apply_mixed_datetimelike (self ):
62
68
# mixed datetimelike
63
69
# GH 7778
You can’t perform that action at this time.
0 commit comments