

def _ensure_index(index_like, copy=False):
    if isinstance(index_like, Index):
        if copy:
            index_like = index_like.copy()
        return index_like
    if hasattr(index_like, 'name'):
        return Index(index_like, name=index_like.name, copy=copy)
    if isinstance(index_like, list):
        if (type(index_like) != list):
            index_like = list(index_like)
        (converted, all_arrays) = lib.clean_index_list(index_like)
        if ((len(converted) > 0) and all_arrays):
            from .multi import MultiIndex
            return MultiIndex.from_arrays(converted)
        else:
            index_like = converted
    elif copy:
        from copy import copy
        index_like = copy(index_like)
    return Index(index_like)

dataset/ETHPy150Open pydata/pandas/pandas/indexes/base.py _ensure_index/original