def makeCustomIndex(nentries, nlevels, prefix='<STR_LIT:#>', names=False, ndupe_l=None,<EOL>idx_type=None):
if ndupe_l is None:<EOL><INDENT>ndupe_l = [<NUM_LIT:1>] * nlevels<EOL><DEDENT>assert (is_sequence(ndupe_l) and len(ndupe_l) <= nlevels)<EOL>assert (names is None or names is False or<EOL>names is True or len(names) is nlevels)<EOL>assert idx_type is None or (idx_type in ('<STR_LIT:i>', '<STR_LIT:f>', '<STR_LIT:s>', '<STR_LIT:u>',<EOL>'<STR_LIT>', '<STR_LIT:p>', '<STR_LIT>')<EOL>and nlevels == <NUM_LIT:1>)<EOL>if names is True:<EOL><INDENT>names = [prefix + str(i) for i in range(nlevels)]<EOL><DEDENT>if names is False:<EOL><INDENT>names = None<EOL><DEDENT>if isinstance(names, str) and nlevels == <NUM_LIT:1>:<EOL><INDENT>names = [names]<EOL><DEDENT>idx_func = dict(i=makeIntIndex, f=makeFloatIndex,<EOL>s=makeStringIndex, u=makeUnicodeIndex,<EOL>dt=makeDateIndex, td=makeTimedeltaIndex,<EOL>p=makePeriodIndex).get(idx_type)<EOL>if idx_func:<EOL><INDENT>idx = idx_func(nentries)<EOL>if names:<EOL><INDENT>idx.name = names[<NUM_LIT:0>]<EOL><DEDENT>return idx<EOL><DEDENT>elif idx_type is not None:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>.format(idx_type=idx_type))<EOL><DEDENT>if len(ndupe_l) < nlevels:<EOL><INDENT>ndupe_l.extend([<NUM_LIT:1>] * (nlevels - len(ndupe_l)))<EOL><DEDENT>assert len(ndupe_l) == nlevels<EOL>assert all(x > <NUM_LIT:0> for x in ndupe_l)<EOL>tuples = []<EOL>for i in range(nlevels):<EOL><INDENT>def keyfunc(x):<EOL><INDENT>import re<EOL>numeric_tuple = re.sub(r"<STR_LIT>", "<STR_LIT>", x).split("<STR_LIT:_>")<EOL>return lmap(int, numeric_tuple)<EOL><DEDENT>div_factor = nentries // ndupe_l[i] + <NUM_LIT:1><EOL>cnt = Counter()<EOL>for j in range(div_factor):<EOL><INDENT>label = '<STR_LIT>'.format(prefix=prefix, i=i, j=j)<EOL>cnt[label] = ndupe_l[i]<EOL><DEDENT>result = list(sorted(cnt.elements(), key=keyfunc))[:nentries]<EOL>tuples.append(result)<EOL><DEDENT>tuples = lzip(*tuples)<EOL>if nentries == <NUM_LIT:1>:<EOL><INDENT>index = Index(tuples[<NUM_LIT:0>], name=names[<NUM_LIT:0>])<EOL><DEDENT>elif nlevels == <NUM_LIT:1>:<EOL><INDENT>name = None if names is None else names[<NUM_LIT:0>]<EOL>index = Index((x[<NUM_LIT:0>] for x in tuples), name=name)<EOL><DEDENT>else:<EOL><INDENT>index = MultiIndex.from_tuples(tuples, names=names)<EOL><DEDENT>return index<EOL>
Create an index/multindex with given dimensions, levels, names, etc'

    nentries - number of entries in index
    nlevels - number of levels (> 1 produces multindex)
    prefix - a string prefix for labels
    names - (Optional), bool or list of strings. if True will use default
       names, if false will use no names, if a list is given, the name of
       each level in the index will be taken from the list.
    ndupe_l - (Optional), list of ints, the number of rows for which the
       label will repeated at the corresponding level, you can specify just
       the first few, the rest will use the default ndupe_l of 1.
       len(ndupe_l) <= nlevels.
    idx_type - "i"/"f"/"s"/"u"/"dt"/"p"/"td".
       If idx_type is not None, `idx_nlevels` must be 1.
       "i"/"f" creates an integer/float index,
       "s"/"u" creates a string/unicode index
       "dt" create a datetime index.
       "td" create a datetime index.

        if unspecified, string labels will be generated.