def ensure_index_from_sequences(sequences, names=None):
from .multi import MultiIndex<EOL>if len(sequences) == <NUM_LIT:1>:<EOL><INDENT>if names is not None:<EOL><INDENT>names = names[<NUM_LIT:0>]<EOL><DEDENT>return Index(sequences[<NUM_LIT:0>], name=names)<EOL><DEDENT>else:<EOL><INDENT>return MultiIndex.from_arrays(sequences, names=names)<EOL><DEDENT>
Construct an index from sequences of data.

A single sequence returns an Index. Many sequences returns a
MultiIndex.

Parameters
----------
sequences : sequence of sequences
names : sequence of str

Returns
-------
index : Index or MultiIndex

Examples
--------
>>> ensure_index_from_sequences([[1, 2, 3]], names=['name'])
Int64Index([1, 2, 3], dtype='int64', name='name')

>>> ensure_index_from_sequences([['a', 'a'], ['a', 'b']],
                                names=['L1', 'L2'])
MultiIndex(levels=[['a'], ['a', 'b']],
           codes=[[0, 0], [0, 1]],
           names=['L1', 'L2'])

See Also
--------
ensure_index