File tree Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Original file line number Diff line number Diff line change 99from pandas ._typing import Axis , FrameOrSeriesUnion
1010from pandas .util ._decorators import cache_readonly
1111
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+ )
1318from pandas .core .dtypes .generic import ABCSeries
1419
1520from pandas .core .construction import create_series_with_explicit_dtype
@@ -392,12 +397,20 @@ def series_generator(self):
392397 mgr = ser ._mgr
393398 blk = mgr .blocks [0 ]
394399
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
401414
402415 @property
403416 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):
5858 assert isinstance (df ["c0" ].dtype , CategoricalDtype )
5959 assert isinstance (df ["c1" ].dtype , CategoricalDtype )
6060
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+
6167 def test_apply_mixed_datetimelike (self ):
6268 # mixed datetimelike
6369 # GH 7778
You can’t perform that action at this time.
0 commit comments