@@ -65,11 +65,11 @@ def empty(cls, shape, fill_value=np.nan, **kwargs):
65
65
return pd .DataFrame (np .full (shape , fill_value ), ** kwargs )
66
66
67
67
@classmethod
68
- def empty_like (cls , other , fill_value = np .nan ):
68
+ def empty_like (cls , other , fill_value = np .nan , ** kwargs ):
69
69
"""Generate an empty Series/DataFrame like `other` and fill with `fill_value`."""
70
70
if checks .is_series (other ):
71
- return cls .empty (other .shape , fill_value = fill_value , index = other .index , name = other .name )
72
- return cls .empty (other .shape , fill_value = fill_value , index = other .index , columns = other .columns )
71
+ return cls .empty (other .shape , fill_value = fill_value , index = other .index , name = other .name , ** kwargs )
72
+ return cls .empty (other .shape , fill_value = fill_value , index = other .index , columns = other .columns , ** kwargs )
73
73
74
74
# ############# Index and columns ############# #
75
75
@@ -336,10 +336,10 @@ def concat(self_or_cls, *others, keys=None, broadcast_kwargs={}):
336
336
objs = (self_or_cls ._obj ,) + others
337
337
broadcasted = reshape_fns .broadcast (* objs , ** broadcast_kwargs )
338
338
broadcasted = tuple (map (reshape_fns .to_2d , broadcasted ))
339
- concatenated = pd .concat (broadcasted , axis = 1 , keys = keys )
340
- if np .all (concatenated .columns == 0 ):
341
- concatenated .columns = pd .RangeIndex (start = 0 , stop = len (concatenated .columns ), step = 1 )
342
- return concatenated
339
+ out = pd .concat (broadcasted , axis = 1 , keys = keys )
340
+ if not isinstance ( out . columns , pd . MultiIndex ) and np .all (out .columns == 0 ):
341
+ out .columns = pd .RangeIndex (start = 0 , stop = len (out .columns ), step = 1 )
342
+ return out
343
343
344
344
def apply_and_concat (self , ntimes , * args , apply_func = None , to_2d = False , keys = None , ** kwargs ):
345
345
"""Apply `apply_func` `ntimes` times and concatenate the results along columns.
0 commit comments