|
14 | 14 | from pandas.compat.numpy import function as nv |
15 | 15 | from pandas.core.indexes.base import Index, _index_shared_docs |
16 | 16 | from pandas.util._decorators import Appender, cache_readonly |
| 17 | +import pandas.core.dtypes.concat as _concat |
17 | 18 | import pandas.core.indexes.base as ibase |
18 | 19 |
|
19 | 20 | from pandas.core.indexes.numeric import Int64Index |
@@ -443,62 +444,9 @@ def join(self, other, how='left', level=None, return_indexers=False, |
443 | 444 | return super(RangeIndex, self).join(other, how, level, return_indexers, |
444 | 445 | sort) |
445 | 446 |
|
446 | | - def append(self, other): |
447 | | - """ |
448 | | - Append a collection of Index options together |
449 | | -
|
450 | | - Parameters |
451 | | - ---------- |
452 | | - other : Index or list/tuple of indices |
453 | | -
|
454 | | - Returns |
455 | | - ------- |
456 | | - appended : RangeIndex if all indexes are consecutive RangeIndexes, |
457 | | - otherwise Int64Index or Index |
458 | | - """ |
459 | | - |
460 | | - to_concat = [self] |
461 | | - |
462 | | - if isinstance(other, (list, tuple)): |
463 | | - to_concat = to_concat + list(other) |
464 | | - else: |
465 | | - to_concat.append(other) |
466 | | - |
467 | | - if not all([isinstance(i, RangeIndex) for i in to_concat]): |
468 | | - return super(RangeIndex, self).append(other) |
469 | | - |
470 | | - start = step = next = None |
471 | | - |
472 | | - for obj in to_concat: |
473 | | - if not len(obj): |
474 | | - continue |
475 | | - |
476 | | - if start is None: |
477 | | - # This is set by the first non-empty index |
478 | | - start = obj._start |
479 | | - if step is None and len(obj) > 1: |
480 | | - step = obj._step |
481 | | - elif step is None: |
482 | | - # First non-empty index had only one element |
483 | | - if obj._start == start: |
484 | | - return super(RangeIndex, self).append(other) |
485 | | - step = obj._start - start |
486 | | - |
487 | | - non_consecutive = ((step != obj._step and len(obj) > 1) or |
488 | | - (next is not None and obj._start != next)) |
489 | | - if non_consecutive: |
490 | | - return super(RangeIndex, self).append(other) |
491 | | - |
492 | | - if step is not None: |
493 | | - next = obj[-1] + step |
494 | | - |
495 | | - if start is None: |
496 | | - start = obj._start |
497 | | - step = obj._step |
498 | | - stop = obj._stop if next is None else next |
499 | | - names = set([obj.name for obj in to_concat]) |
500 | | - name = None if len(names) > 1 else self.name |
501 | | - return RangeIndex(start, stop, step, name=name) |
| 447 | + def _append_same_dtype(self, indexes, name): |
| 448 | + return _concat._concat_indexes_same_dtype_rangeindex(indexes |
| 449 | + ).rename(name) |
502 | 450 |
|
503 | 451 | def __len__(self): |
504 | 452 | """ |
|
0 commit comments