20
20
21
21
def concat (objs , axis = 0 , join = 'outer' , join_axes = None , ignore_index = False ,
22
22
keys = None , levels = None , names = None , verify_integrity = False ,
23
- copy = True ):
23
+ copy = True , mismatch_sort = False ):
24
24
"""
25
25
Concatenate pandas objects along a particular axis with optional set logic
26
26
along the other axes.
@@ -62,6 +62,8 @@ def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False,
62
62
be very expensive relative to the actual data concatenation
63
63
copy : boolean, default True
64
64
If False, do not copy data unnecessarily
65
+ mismatch_sort : boolean, default False
66
+ Sort columns if all passed object columns are not the same
65
67
66
68
Returns
67
69
-------
@@ -209,7 +211,7 @@ def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False,
209
211
ignore_index = ignore_index , join = join ,
210
212
keys = keys , levels = levels , names = names ,
211
213
verify_integrity = verify_integrity ,
212
- copy = copy )
214
+ copy = copy , sort = mismatch_sort )
213
215
return op .get_result ()
214
216
215
217
@@ -220,7 +222,8 @@ class _Concatenator(object):
220
222
221
223
def __init__ (self , objs , axis = 0 , join = 'outer' , join_axes = None ,
222
224
keys = None , levels = None , names = None ,
223
- ignore_index = False , verify_integrity = False , copy = True ):
225
+ ignore_index = False , verify_integrity = False , copy = True ,
226
+ sort = False ):
224
227
if isinstance (objs , (NDFrame , compat .string_types )):
225
228
raise TypeError ('first argument must be an iterable of pandas '
226
229
'objects, you passed an object of type '
@@ -355,6 +358,7 @@ def __init__(self, objs, axis=0, join='outer', join_axes=None,
355
358
self .keys = keys
356
359
self .names = names or getattr (keys , 'names' , None )
357
360
self .levels = levels
361
+ self .sort = sort
358
362
359
363
self .ignore_index = ignore_index
360
364
self .verify_integrity = verify_integrity
@@ -447,7 +451,8 @@ def _get_comb_axis(self, i):
447
451
data_axis = self .objs [0 ]._get_block_manager_axis (i )
448
452
try :
449
453
return _get_objs_combined_axis (self .objs , axis = data_axis ,
450
- intersect = self .intersect )
454
+ intersect = self .intersect ,
455
+ sort = self .sort )
451
456
except IndexError :
452
457
types = [type (x ).__name__ for x in self .objs ]
453
458
raise TypeError ("Cannot concatenate list of {types}"
0 commit comments