@@ -1693,7 +1693,9 @@ def info(self, verbose=True, buf=None, max_cols=None):
1693
1693
1694
1694
@property
1695
1695
def dtypes (self ):
1696
- return self .apply (lambda x : x .dtype )
1696
+ dtypes = self .apply (lambda x : x .dtype )
1697
+ dtypes .name = 'dtypes'
1698
+ return dtypes
1697
1699
1698
1700
def convert_objects (self , convert_dates = True , convert_numeric = False , copy = True ):
1699
1701
"""
@@ -4395,20 +4397,28 @@ def apply(self, func, axis=0, broadcast=False, raw=False,
4395
4397
return self ._constructor (data = results , index = self .index ,
4396
4398
columns = self .columns , copy = False )
4397
4399
else :
4400
+ #if not all(self.shape):
4401
+ # broadcast = True
4402
+
4398
4403
if not broadcast :
4399
4404
if not all (self .shape ):
4400
- # How to determine this better?
4401
- is_reduction = False
4402
- try :
4403
- is_reduction = not isinstance (f (_EMPTY_SERIES ),
4404
- np .ndarray )
4405
- except Exception :
4406
- pass
4405
+ if axis :
4406
+ result = self ._constructor ([f (self .iloc [i , :])
4407
+ for i , _ in enumerate (self .index )],
4408
+ index = self .index )
4409
+ else :
4410
+ result = self ._constructor ([f (self .iloc [:, i ])
4411
+ for i , _ in enumerate (self .columns )],
4412
+ index = self .columns )
4413
+
4414
+ # are these the only cases when we flatten?
4415
+ if len (result .columns ) == 1 :
4416
+ return result .iloc [:, 0 ]
4407
4417
4408
- if is_reduction :
4409
- return Series (NA , index = self . _get_agg_axis ( axis ) )
4418
+ elif not len ( result . index ) :
4419
+ return Series (NA , index = result . columns )
4410
4420
else :
4411
- return self . copy ()
4421
+ return result
4412
4422
4413
4423
if raw and not self ._is_mixed_type :
4414
4424
return self ._apply_raw (f , axis )
0 commit comments