code: def set_default_names(data):
      
      if all(name is not None for name in data.index.names):
          return data
  
      data = data.copy()
      if data.index.nlevels > 1:
          names = [name if name is not None else 'level_{}'.format(i)
                   for i, name in enumerate(data.index.names)]
          data.index.names = names
      else:
          data.index.name = data.index.name or 'index'
      return data
docs: Sets index names to 'index' for regular, or 'level_x' for Multi