@@ -220,27 +220,32 @@ def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False,
220
220
...
221
221
ValueError: Indexes have overlapping values: ['a']
222
222
"""
223
+ op = _Concatenator (objs , axis = axis , ignore_index = ignore_index , join = join ,
224
+ keys = keys , levels = levels , names = names ,
225
+ verify_integrity = verify_integrity , copy = copy , sort = sort )
226
+
227
+ res = op .get_result ()
228
+
223
229
if join_axes is not None :
224
230
warnings .warn ('The join_axes-keyword is deprecated. Use .reindex or '
225
231
'.reindex_like on the result to achieve the same '
226
232
'functionality.' , FutureWarning , stacklevel = 2 )
227
- op = _Concatenator ( objs , axis = axis , join_axes = join_axes ,
228
- ignore_index = ignore_index , join = join ,
229
- keys = keys , levels = levels , names = names ,
230
- verify_integrity = verify_integrity ,
231
- copy = copy , sort = sort )
232
- return op . get_result ()
233
+ if len ( join_axes ) > 1 :
234
+ raise AssertionError ( "join_axes must be a list of indexes of "
235
+ "length {length}" . format ( length = 1 ))
236
+ other_axis = 1 if axis == 0 else 0 # switches between 0 & 1
237
+ res = res . reindex ( join_axes [ 0 ], axis = other_axis )
238
+ return res
233
239
234
240
235
241
class _Concatenator (object ):
236
242
"""
237
243
Orchestrates a concatenation operation for BlockManagers
238
244
"""
239
245
240
- def __init__ (self , objs , axis = 0 , join = 'outer' , join_axes = None ,
241
- keys = None , levels = None , names = None ,
242
- ignore_index = False , verify_integrity = False , copy = True ,
243
- sort = False ):
246
+ def __init__ (self , objs , axis = 0 , join = 'outer' , keys = None , levels = None ,
247
+ names = None , ignore_index = False , verify_integrity = False ,
248
+ copy = True , sort = False ):
244
249
if isinstance (objs , (NDFrame , compat .string_types )):
245
250
raise TypeError ('first argument must be an iterable of pandas '
246
251
'objects, you passed an object of type '
@@ -313,9 +318,7 @@ def __init__(self, objs, axis=0, join='outer', join_axes=None,
313
318
if sum (obj .shape ) > 0 or isinstance (obj , Series )]
314
319
315
320
if (len (non_empties ) and (keys is None and names is None and
316
- levels is None and
317
- join_axes is None and
318
- not self .intersect )):
321
+ levels is None and not self .intersect )):
319
322
objs = non_empties
320
323
sample = objs [0 ]
321
324
@@ -371,7 +374,6 @@ def __init__(self, objs, axis=0, join='outer', join_axes=None,
371
374
372
375
# note: this is the BlockManager axis (since DataFrame is transposed)
373
376
self .axis = axis
374
- self .join_axes = join_axes
375
377
self .keys = keys
376
378
self .names = names or getattr (keys , 'names' , None )
377
379
self .levels = levels
@@ -444,22 +446,10 @@ def _get_new_axes(self):
444
446
ndim = self ._get_result_dim ()
445
447
new_axes = [None ] * ndim
446
448
447
- if self .join_axes is None :
448
- for i in range (ndim ):
449
- if i == self .axis :
450
- continue
451
- new_axes [i ] = self ._get_comb_axis (i )
452
- else :
453
- if len (self .join_axes ) != ndim - 1 :
454
- raise AssertionError ("length of join_axes must not be equal "
455
- "to {length}" .format (length = ndim - 1 ))
456
-
457
- # ufff...
458
- indices = compat .lrange (ndim )
459
- indices .remove (self .axis )
460
-
461
- for i , ax in zip (indices , self .join_axes ):
462
- new_axes [i ] = ax
449
+ for i in range (ndim ):
450
+ if i == self .axis :
451
+ continue
452
+ new_axes [i ] = self ._get_comb_axis (i )
463
453
464
454
new_axes [self .axis ] = self ._get_concat_axis ()
465
455
return new_axes
0 commit comments