def create_index(self, columns=None, optlevel=None, kind=None):
if not self.infer_axes():<EOL><INDENT>return<EOL><DEDENT>if columns is False:<EOL><INDENT>return<EOL><DEDENT>if columns is None or columns is True:<EOL><INDENT>columns = [a.cname for a in self.axes if a.is_data_indexable]<EOL><DEDENT>if not isinstance(columns, (tuple, list)):<EOL><INDENT>columns = [columns]<EOL><DEDENT>kw = dict()<EOL>if optlevel is not None:<EOL><INDENT>kw['<STR_LIT>'] = optlevel<EOL><DEDENT>if kind is not None:<EOL><INDENT>kw['<STR_LIT>'] = kind<EOL><DEDENT>table = self.table<EOL>for c in columns:<EOL><INDENT>v = getattr(table.cols, c, None)<EOL>if v is not None:<EOL><INDENT>if v.is_indexed:<EOL><INDENT>index = v.index<EOL>cur_optlevel = index.optlevel<EOL>cur_kind = index.kind<EOL>if kind is not None and cur_kind != kind:<EOL><INDENT>v.remove_index()<EOL><DEDENT>else:<EOL><INDENT>kw['<STR_LIT>'] = cur_kind<EOL><DEDENT>if optlevel is not None and cur_optlevel != optlevel:<EOL><INDENT>v.remove_index()<EOL><DEDENT>else:<EOL><INDENT>kw['<STR_LIT>'] = cur_optlevel<EOL><DEDENT><DEDENT>if not v.is_indexed:<EOL><INDENT>if v.type.startswith('<STR_LIT>'):<EOL><INDENT>raise TypeError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>v.create_index(**kw)<EOL><DEDENT><DEDENT><DEDENT>
Create a pytables index on the specified columns
  note: cannot index Time64Col() or ComplexCol currently;
  PyTables must be >= 3.0

Parameters
----------
columns : False (don't create an index), True (create all columns
    index), None or list_like (the indexers to index)
optlevel: optimization level (defaults to 6)
kind    : kind of index (defaults to 'medium')

Exceptions
----------
raises if the node is not a table