Skip to content

Commit d3c062b

Browse files
author
y-p
committed
CLN: Move _is_sequence() from pd.frame to pd.common, with other is_*
1 parent 5d03a6b commit d3c062b

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

pandas/core/common.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,14 @@ def is_float_dtype(arr_or_dtype):
778778
def is_list_like(arg):
779779
return hasattr(arg, '__iter__') and not isinstance(arg, basestring)
780780

781+
def _is_sequence(x):
782+
try:
783+
iter(x)
784+
assert(not isinstance(x, basestring))
785+
return True
786+
except Exception:
787+
return False
788+
781789
_ensure_float64 = _algos.ensure_float64
782790
_ensure_int64 = _algos.ensure_int64
783791
_ensure_int32 = _algos.ensure_int32

pandas/core/frame.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import numpy.ma as ma
2626

2727
from pandas.core.common import (isnull, notnull, PandasError, _try_sort,
28-
_default_index, _stringify)
28+
_default_index,_stringify,_is_sequence)
2929
from pandas.core.generic import NDFrame
3030
from pandas.core.index import Index, MultiIndex, _ensure_index
3131
from pandas.core.indexing import _NDFrameIndexer, _maybe_droplevels
@@ -5106,14 +5106,6 @@ def _homogenize(data, index, columns, dtype=None):
51065106
def _put_str(s, space):
51075107
return ('%s' % s)[:space].ljust(space)
51085108

5109-
def _is_sequence(x):
5110-
try:
5111-
iter(x)
5112-
assert(not isinstance(x, basestring))
5113-
return True
5114-
except Exception:
5115-
return False
5116-
51175109
def install_ipython_completers(): # pragma: no cover
51185110
"""Register the DataFrame type with IPython's tab completion machinery, so
51195111
that it knows about accessing column names as attributes."""

0 commit comments

Comments
 (0)