Skip to content

Commit f4b1c6d

Browse files
committed
Merge pull request #8959 from vikram/8933
Fixes #8933 simple renaming
2 parents e463818 + 8154f0d commit f4b1c6d

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

pandas/core/categorical.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from pandas.core.common import (CategoricalDtype, ABCSeries, isnull, notnull,
1919
is_categorical_dtype, is_integer_dtype, is_object_dtype,
2020
_possibly_infer_to_datetimelike, get_dtype_kinds,
21-
is_list_like, _is_sequence,
21+
is_list_like, is_sequence,
2222
_ensure_platform_int, _ensure_object, _ensure_int64,
2323
_coerce_indexer_dtype, _values_from_object, take_1d)
2424
from pandas.util.terminal import get_terminal_size
@@ -1477,7 +1477,7 @@ def _convert_to_list_like(list_like):
14771477
return list_like
14781478
if isinstance(list_like, list):
14791479
return list_like
1480-
if (_is_sequence(list_like) or isinstance(list_like, tuple)
1480+
if (is_sequence(list_like) or isinstance(list_like, tuple)
14811481
or isinstance(list_like, types.GeneratorType)):
14821482
return list(list_like)
14831483
elif np.isscalar(list_like):

pandas/core/common.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -2504,14 +2504,15 @@ def is_list_like(arg):
25042504
not isinstance(arg, compat.string_and_binary_types))
25052505

25062506

2507-
def _is_sequence(x):
2507+
def is_sequence(x):
25082508
try:
25092509
iter(x)
25102510
len(x) # it has a length
25112511
return not isinstance(x, compat.string_and_binary_types)
25122512
except (TypeError, AttributeError):
25132513
return False
25142514

2515+
25152516
def _get_callable_name(obj):
25162517
# typical case has name
25172518
if hasattr(obj, '__name__'):
@@ -3093,7 +3094,7 @@ def as_escaped_unicode(thing, escape_chars=escape_chars):
30933094
elif (isinstance(thing, dict) and
30943095
_nest_lvl < get_option("display.pprint_nest_depth")):
30953096
result = _pprint_dict(thing, _nest_lvl, quote_strings=True)
3096-
elif _is_sequence(thing) and _nest_lvl < \
3097+
elif is_sequence(thing) and _nest_lvl < \
30973098
get_option("display.pprint_nest_depth"):
30983099
result = _pprint_seq(thing, _nest_lvl, escape_chars=escape_chars,
30993100
quote_strings=quote_strings)

pandas/core/frame.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import numpy.ma as ma
2525

2626
from pandas.core.common import (isnull, notnull, PandasError, _try_sort,
27-
_default_index, _maybe_upcast, _is_sequence,
27+
_default_index, _maybe_upcast, is_sequence,
2828
_infer_dtype_from_scalar, _values_from_object,
2929
is_list_like, _get_dtype, _maybe_box_datetimelike,
3030
is_categorical_dtype)
@@ -2255,7 +2255,7 @@ def reindexer(value):
22552255
elif isinstance(value, Categorical):
22562256
value = value.copy()
22572257

2258-
elif (isinstance(value, Index) or _is_sequence(value)):
2258+
elif (isinstance(value, Index) or is_sequence(value)):
22592259
from pandas.core.series import _sanitize_index
22602260
value = _sanitize_index(value, self.index, copy=False)
22612261
if not isinstance(value, (np.ndarray, Index)):
@@ -2844,7 +2844,7 @@ def sort_index(self, axis=0, by=None, ascending=True, inplace=False,
28442844
'(rows)')
28452845
if not isinstance(by, list):
28462846
by = [by]
2847-
if com._is_sequence(ascending) and len(by) != len(ascending):
2847+
if com.is_sequence(ascending) and len(by) != len(ascending):
28482848
raise ValueError('Length of ascending (%d) != length of by'
28492849
' (%d)' % (len(ascending), len(by)))
28502850
if len(by) > 1:
@@ -3694,7 +3694,7 @@ def _apply_standard(self, func, axis, ignore_failures=False, reduce=True):
36943694
com.pprint_thing(k),)
36953695
raise
36963696

3697-
if len(results) > 0 and _is_sequence(results[0]):
3697+
if len(results) > 0 and is_sequence(results[0]):
36983698
if not isinstance(results[0], Series):
36993699
index = res_columns
37003700
else:

pandas/core/indexing.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def _align_series(self, indexer, ser):
541541
# we have a frame, with multiple indexers on both axes; and a
542542
# series, so need to broadcast (see GH5206)
543543
if (sum_aligners == self.ndim and
544-
all([com._is_sequence(_) for _ in indexer])):
544+
all([com.is_sequence(_) for _ in indexer])):
545545
ser = ser.reindex(obj.axes[0][indexer[0]], copy=True).values
546546

547547
# single indexer
@@ -555,7 +555,7 @@ def _align_series(self, indexer, ser):
555555
ax = obj.axes[i]
556556

557557
# multiple aligners (or null slices)
558-
if com._is_sequence(idx) or isinstance(idx, slice):
558+
if com.is_sequence(idx) or isinstance(idx, slice):
559559
if single_aligner and _is_null_slice(idx):
560560
continue
561561
new_ix = ax[idx]
@@ -625,7 +625,7 @@ def _align_frame(self, indexer, df):
625625
sindexers = []
626626
for i, ix in enumerate(indexer):
627627
ax = self.obj.axes[i]
628-
if com._is_sequence(ix) or isinstance(ix, slice):
628+
if com.is_sequence(ix) or isinstance(ix, slice):
629629
if idx is None:
630630
idx = ax[ix].ravel()
631631
elif cols is None:

pandas/tests/test_common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_mut_exclusive():
2525

2626

2727
def test_is_sequence():
28-
is_seq = com._is_sequence
28+
is_seq = com.is_sequence
2929
assert(is_seq((1, 2)))
3030
assert(is_seq([1, 2]))
3131
assert(not is_seq("abcd"))

pandas/util/testing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from numpy.testing import assert_array_equal
2525

2626
import pandas as pd
27-
from pandas.core.common import _is_sequence, array_equivalent, is_list_like
27+
from pandas.core.common import is_sequence, array_equivalent, is_list_like
2828
import pandas.core.index as index
2929
import pandas.core.series as series
3030
import pandas.core.frame as frame
@@ -945,7 +945,7 @@ def makeCustomIndex(nentries, nlevels, prefix='#', names=False, ndupe_l=None,
945945

946946
if ndupe_l is None:
947947
ndupe_l = [1] * nlevels
948-
assert (_is_sequence(ndupe_l) and len(ndupe_l) <= nlevels)
948+
assert (is_sequence(ndupe_l) and len(ndupe_l) <= nlevels)
949949
assert (names is None or names is False
950950
or names is True or len(names) is nlevels)
951951
assert idx_type is None or \

0 commit comments

Comments
 (0)