def _transform_index(index, func):
 if isinstance(index, MultiIndex):
  items = [tuple((func(y) for y in x)) for x in index]
  return MultiIndex.from_tuples(items, names=index.names)
 else:
  items = [func(x) for x in index]
  return Index(items, name=index.name)

def _transform_index ( index , func ) : if isinstance ( index , MultiIndex ) : items = [ tuple ( ( func ( y ) for y in x ) ) for x in index ] return MultiIndex . from_tuples ( items , names = index . names ) else : items = [ func ( x ) for x in index ] return Index ( items , name = index . name )
apply function to all values found in index .