parameters: (
          self, mapper: Union[Mapping[Any, Any], Callable], level: Optional[int]
      )
return_statement: return self.__class__(ca)
docstring: Rename the specified levels of the given ColumnAccessor
  
          Parameters
          ----------
          self : ColumnAccessor of a given dataframe
  
          mapper : dict-like or function transformations to apply to
              the column label values depending on selected ``level``.
  
              If dict-like, only replace the specified level of the
              ColumnAccessor's keys (that match the mapper's keys) with
              mapper's values
  
              If callable, the function is applied only to the specified level
              of the ColumnAccessor's keys.
  
          level : int
              In case of RangeIndex, only supported level is [0, None].
              In case of a MultiColumn, only the column labels in the specified
              level of the ColumnAccessor's keys will be transformed.
  
          Returns
          -------
          A new ColumnAccessor with values in the keys replaced according
          to the given mapper and level.
docstring_summary: Rename the specified levels of the given ColumnAccessor
docstring_tokens: Rename the specified levels of the given ColumnAccessor
function: def rename_levels(
          self, mapper: Union[Mapping[Any, Any], Callable], level: Optional[int]
      ) -> ColumnAccessor:
          """
          Rename the specified levels of the given ColumnAccessor
  
          Parameters
          ----------
          self : ColumnAccessor of a given dataframe
  
          mapper : dict-like or function transformations to apply to
              the column label values depending on selected ``level``.
  
              If dict-like, only replace the specified level of the
              ColumnAccessor's keys (that match the mapper's keys) with
              mapper's values
  
              If callable, the function is applied only to the specified level
              of the ColumnAccessor's keys.
  
          level : int
              In case of RangeIndex, only supported level is [0, None].
              In case of a MultiColumn, only the column labels in the specified
              level of the ColumnAccessor's keys will be transformed.
  
          Returns
          -------
          A new ColumnAccessor with values in the keys replaced according
          to the given mapper and level.
  
          """
          if self.multiindex:
  
              def rename_column(x):
                  x = list(x)
                  if isinstance(mapper, Mapping):
                      x[level] = mapper.get(x[level], x[level])
                  else:
                      x[level] = mapper(x[level])
                  x = tuple(x)
                  return x
  
              if level is None:
                  raise NotImplementedError(
                      "Renaming columns with a MultiIndex and level=None is"
                      "not supported"
                  )
              new_names = map(rename_column, self.keys())
              ca = ColumnAccessor(
                  dict(zip(new_names, self.values())),
                  level_names=self.level_names,
                  multiindex=self.multiindex,
              )
  
          else:
              if level is None:
                  level = 0
              if level != 0:
                  raise IndexError(
                      f"Too many levels: Index has only 1 level, not {level+1}"
                  )
  
              if isinstance(mapper, Mapping):
                  new_col_names = [
                      mapper.get(col_name, col_name) for col_name in self.keys()
                  ]
              else:
                  new_col_names = [mapper(col_name) for col_name in self.keys()]
  
              if len(new_col_names) != len(set(new_col_names)):
                  raise ValueError("Duplicate column names are not allowed")
  
              ca = ColumnAccessor(
                  dict(zip(new_col_names, self.values())),
                  level_names=self.level_names,
                  multiindex=self.multiindex,
              )
  
          return self.__class__(ca)
function_tokens: def rename_levels ( self , mapper : Union [ Mapping [ Any , Any ] , Callable ] , level : Optional [ int ] ) -> ColumnAccessor : if self . multiindex : def rename_column ( x ) : x = list ( x ) if isinstance ( mapper , Mapping ) : x [ level ] = mapper . get ( x [ level ] , x [ level ] ) else : x [ level ] = mapper ( x [ level ] ) x = tuple ( x ) return x if level is None : raise NotImplementedError ( "Renaming columns with a MultiIndex and level=None is" "not supported" ) new_names = map ( rename_column , self . keys ( ) ) ca = ColumnAccessor ( dict ( zip ( new_names , self . values ( ) ) ) , level_names = self . level_names , multiindex = self . multiindex , ) else : if level is None : level = 0 if level != 0 : raise IndexError ( f"Too many levels: Index has only 1 level, not {level+1}" ) if isinstance ( mapper , Mapping ) : new_col_names = [ mapper . get ( col_name , col_name ) for col_name in self . keys ( ) ] else : new_col_names = [ mapper ( col_name ) for col_name in self . keys ( ) ] if len ( new_col_names ) != len ( set ( new_col_names ) ) : raise ValueError ( "Duplicate column names are not allowed" ) ca = ColumnAccessor ( dict ( zip ( new_col_names , self . values ( ) ) ) , level_names = self . level_names , multiindex = self . multiindex , ) return self . __class__ ( ca )