|
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 |
@@ -447,62 +448,8 @@ def join(self, other, how='left', level=None, return_indexers=False, |
447 | 448 | return super(RangeIndex, self).join(other, how, level, return_indexers, |
448 | 449 | sort) |
449 | 450 |
|
450 | | - def append(self, other): |
451 | | - """ |
452 | | - Append a collection of Index options together |
453 | | -
|
454 | | - Parameters |
455 | | - ---------- |
456 | | - other : Index or list/tuple of indices |
457 | | -
|
458 | | - Returns |
459 | | - ------- |
460 | | - appended : RangeIndex if all indexes are consecutive RangeIndexes, |
461 | | - otherwise Int64Index or Index |
462 | | - """ |
463 | | - |
464 | | - to_concat = [self] |
465 | | - |
466 | | - if isinstance(other, (list, tuple)): |
467 | | - to_concat = to_concat + list(other) |
468 | | - else: |
469 | | - to_concat.append(other) |
470 | | - |
471 | | - if not all([isinstance(i, RangeIndex) for i in to_concat]): |
472 | | - return super(RangeIndex, self).append(other) |
473 | | - |
474 | | - start = step = next = None |
475 | | - |
476 | | - for obj in to_concat: |
477 | | - if not len(obj): |
478 | | - continue |
479 | | - |
480 | | - if start is None: |
481 | | - # This is set by the first non-empty index |
482 | | - start = obj._start |
483 | | - if step is None and len(obj) > 1: |
484 | | - step = obj._step |
485 | | - elif step is None: |
486 | | - # First non-empty index had only one element |
487 | | - if obj._start == start: |
488 | | - return super(RangeIndex, self).append(other) |
489 | | - step = obj._start - start |
490 | | - |
491 | | - non_consecutive = ((step != obj._step and len(obj) > 1) or |
492 | | - (next is not None and obj._start != next)) |
493 | | - if non_consecutive: |
494 | | - return super(RangeIndex, self).append(other) |
495 | | - |
496 | | - if step is not None: |
497 | | - next = obj[-1] + step |
498 | | - |
499 | | - if start is None: |
500 | | - start = obj._start |
501 | | - step = obj._step |
502 | | - stop = obj._stop if next is None else next |
503 | | - names = set([obj.name for obj in to_concat]) |
504 | | - name = None if len(names) > 1 else self.name |
505 | | - return RangeIndex(start, stop, step, name=name) |
| 451 | + def _concat_same_dtype(self, indexes, name): |
| 452 | + return _concat._concat_rangeindex_same_dtype(indexes).rename(name) |
506 | 453 |
|
507 | 454 | def __len__(self): |
508 | 455 | """ |
|
0 commit comments