def _set_index(self, key, index):
axis = key[<NUM_LIT:0>]<EOL>origin = "<STR_LIT>".format(axis)<EOL>delta = "<STR_LIT>".format(axis)<EOL>if index is None:<EOL><INDENT>return delattr(self, key)<EOL><DEDENT>if not isinstance(index, Index):<EOL><INDENT>try:<EOL><INDENT>unit = index.unit<EOL><DEDENT>except AttributeError:<EOL><INDENT>unit = getattr(self, "<STR_LIT>".format(axis))<EOL><DEDENT>index = Index(index, unit=unit, copy=False)<EOL><DEDENT>setattr(self, origin, index[<NUM_LIT:0>])<EOL>if index.regular:<EOL><INDENT>setattr(self, delta, index[<NUM_LIT:1>] - index[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>delattr(self, delta)<EOL><DEDENT>setattr(self, "<STR_LIT>".format(key), index)<EOL>
Set a new index array for this series