parameters: (index, func, level=None)
docstring: Apply function to all values found in index.
  
      This includes transforming multiindex entries separately.
      Only apply function to one level of the MultiIndex if level is specified.
docstring_summary: Apply function to all values found in index.
docstring_tokens: Apply function to all values found in index .
function: def _transform_index(index, func, level=None):
      """
      Apply function to all values found in index.
  
      This includes transforming multiindex entries separately.
      Only apply function to one level of the MultiIndex if level is specified.
  
      """
      if isinstance(index, MultiIndex):
          if level is not None:
              items = [
                  tuple(func(y) if i == level else y for i, y in enumerate(x))
                  for x in index
              ]
          else:
              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, tupleize_cols=False)
function_tokens: def _transform_index ( index , func , level = None ) : if isinstance ( index , MultiIndex ) : if level is not None : items = [ tuple ( func ( y ) if i == level else y for i , y in enumerate ( x ) ) for x in index ] else : 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 , tupleize_cols = False )