Skip to content

Commit 528295d

Browse files
committed
Removed is_range, renamed _concat_rangeindex_same_dtype
1 parent 44800a4 commit 528295d

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

pandas/core/dtypes/common.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .generic import (ABCCategorical, ABCPeriodIndex,
1313
ABCDatetimeIndex, ABCSeries,
1414
ABCSparseArray, ABCSparseSeries, ABCCategoricalIndex,
15-
ABCIndexClass, ABCRangeIndex)
15+
ABCIndexClass)
1616
from .inference import is_string_like
1717
from .inference import * # noqa
1818

@@ -220,10 +220,6 @@ def is_categorical(arr):
220220
return isinstance(arr, ABCCategorical) or is_categorical_dtype(arr)
221221

222222

223-
def is_range(arr):
224-
return isinstance(arr, ABCRangeIndex)
225-
226-
227223
def is_datetimetz(arr):
228224
"""
229225
Check whether an array-like is a datetime array-like with a timezone

pandas/core/dtypes/concat.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
is_object_dtype,
1616
is_bool_dtype,
1717
is_dtype_equal,
18-
is_range,
1918
_NS_DTYPE,
2019
_TD_DTYPE)
2120
from pandas.core.dtypes.generic import (
2221
ABCDatetimeIndex, ABCTimedeltaIndex,
23-
ABCPeriodIndex)
22+
ABCPeriodIndex, ABCRangeIndex)
2423

2524

2625
def get_dtype_kinds(l):
@@ -42,12 +41,12 @@ def get_dtype_kinds(l):
4241
typ = 'category'
4342
elif is_sparse(arr):
4443
typ = 'sparse'
44+
elif isinstance(arr, ABCRangeIndex):
45+
typ = 'range'
4546
elif is_datetimetz(arr):
4647
# if to_concat contains different tz,
4748
# the result must be object dtype
4849
typ = str(arr.dtype)
49-
elif is_range(arr):
50-
typ = 'range'
5150
elif is_datetime64_dtype(dtype):
5251
typ = 'datetime'
5352
elif is_timedelta64_dtype(dtype):
@@ -564,12 +563,14 @@ def convert_sparse(x, axis):
564563
return result
565564

566565

567-
def _concat_indexes_same_dtype_rangeindex(indexes):
568-
# Concatenates multiple RangeIndex instances. All members of "indexes" must
569-
# be of type RangeIndex; result will be RangeIndex if possible, Int64Index
570-
# otherwise. E.g.:
571-
# indexes = [RangeIndex(3), RangeIndex(3, 6)] -> RangeIndex(6)
572-
# indexes = [RangeIndex(3), RangeIndex(4, 6)] -> Int64Index([0,1,2,4,5])
566+
def _concat_rangeindex_same_dtype(indexes):
567+
"""
568+
Concatenates multiple RangeIndex instances. All members of "indexes" must
569+
be of type RangeIndex; result will be RangeIndex if possible, Int64Index
570+
otherwise. E.g.:
571+
indexes = [RangeIndex(3), RangeIndex(3, 6)] -> RangeIndex(6)
572+
indexes = [RangeIndex(3), RangeIndex(4, 6)] -> Int64Index([0,1,2,4,5])
573+
"""
573574

574575
start = step = next = None
575576

pandas/core/indexes/range.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,7 @@ def join(self, other, how='left', level=None, return_indexers=False,
445445
sort)
446446

447447
def _append_same_dtype(self, indexes, name):
448-
return _concat._concat_indexes_same_dtype_rangeindex(indexes
449-
).rename(name)
448+
return _concat._concat_rangeindex_same_dtype(indexes).rename(name)
450449

451450
def __len__(self):
452451
"""

0 commit comments

Comments
 (0)