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
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
@@ -407,12 +412,20 @@ def series_generator(self):
407
412
mgr = ser ._mgr
408
413
blk = mgr .blocks [0 ]
409
414
410
- for (arr , name ) in zip (values , self .index ):
411
- # GH#35462 re-pin mgr in case setitem changed it
412
- ser ._mgr = mgr
413
- blk .values = arr
414
- ser .name = name
415
- yield ser
415
+ if is_extension_array_dtype (blk .dtype ):
416
+ # values will be incorrect for this block
417
+ # TODO(EA2D): special case would be unnecessary with 2D EAs
418
+ obj = self .obj
419
+ for i in range (len (obj )):
420
+ yield obj ._ixs (i , axis = 0 )
421
+
422
+ else :
423
+ for (arr , name ) in zip (values , self .index ):
424
+ # GH#35462 re-pin mgr in case setitem changed it
425
+ ser ._mgr = mgr
426
+ blk .values = arr
427
+ ser .name = name
428
+ yield ser
416
429
417
430
@property
418
431
def result_index (self ) -> "Index" :
Original file line number Diff line number Diff line change @@ -60,6 +60,12 @@ def test_apply(self, float_frame):
60
60
assert isinstance (df ["c0" ].dtype , CategoricalDtype )
61
61
assert isinstance (df ["c1" ].dtype , CategoricalDtype )
62
62
63
+ def test_apply_axis1_with_ea (self ):
64
+ # GH#36785
65
+ df = DataFrame ({"A" : [Timestamp ("2013-01-01" , tz = "UTC" )]})
66
+ result = df .apply (lambda x : x , axis = 1 )
67
+ tm .assert_frame_equal (result , df )
68
+
63
69
def test_apply_mixed_datetimelike (self ):
64
70
# mixed datetimelike
65
71
# GH 7778
You can’t perform that action at this time.
0 commit comments