|
24 | 24 | from pandas.core.common import (isnull, notnull, PandasError, _try_sort,
|
25 | 25 | _default_index, _maybe_upcast, _is_sequence,
|
26 | 26 | _infer_dtype_from_scalar, _values_from_object,
|
27 |
| - _coerce_to_dtypes, _DATELIKE_DTYPES) |
| 27 | + _coerce_to_dtypes, _DATELIKE_DTYPES, is_list_like) |
28 | 28 | from pandas.core.generic import NDFrame
|
29 | 29 | from pandas.core.index import Index, MultiIndex, _ensure_index
|
30 | 30 | from pandas.core.indexing import (_NDFrameIndexer, _maybe_droplevels,
|
@@ -418,7 +418,7 @@ def __init__(self, data=None, index=None, columns=None, dtype=None,
|
418 | 418 | if index is None and isinstance(data[0], Series):
|
419 | 419 | index = _get_names_from_index(data)
|
420 | 420 |
|
421 |
| - if isinstance(data[0], (list, tuple, collections.Mapping, Series)): |
| 421 | + if is_list_like(data[0]) and getattr(data[0],'ndim',0) <= 1: |
422 | 422 | arrays, columns = _to_arrays(data, columns, dtype=dtype)
|
423 | 423 | columns = _ensure_index(columns)
|
424 | 424 |
|
@@ -4545,7 +4545,7 @@ def isin(self, values, iloc=False):
|
4545 | 4545 |
|
4546 | 4546 |
|
4547 | 4547 | else:
|
4548 |
| - if not com.is_list_like(values): |
| 4548 | + if not is_list_like(values): |
4549 | 4549 | raise TypeError("only list-like or dict-like objects are"
|
4550 | 4550 | " allowed to be passed to DataFrame.isin(), "
|
4551 | 4551 | "you passed a "
|
@@ -4705,7 +4705,7 @@ def extract_index(data):
|
4705 | 4705 | elif isinstance(v, dict):
|
4706 | 4706 | have_dicts = True
|
4707 | 4707 | indexes.append(list(v.keys()))
|
4708 |
| - elif isinstance(v, (list, tuple, np.ndarray)): |
| 4708 | + elif is_list_like(v) and getattr(v,'ndim',0) <= 1: |
4709 | 4709 | have_raw_arrays = True
|
4710 | 4710 | raw_lengths.append(len(v))
|
4711 | 4711 |
|
|
0 commit comments