class_docstr: Namespace for expressions that operate on expression names.
docstr: Rename the output of an expression by mapping a function over the root name.
  
  Parameters
  ----------
  function
      Function that maps a root name to a new name.
  
  See Also
  --------
  keep
  prefix
  suffix
  
  Examples
  --------
  Remove a common suffix and convert to lower case.
  
  >>> df = pl.DataFrame(
  ...     {
  ...         "A_reverse": [3, 2, 1],
  ...         "B_reverse": ["z", "y", "x"],
  ...     }
  ... )
  >>> df.with_columns(
  ...     pl.all().reverse().name.map(lambda c: c.rstrip("_reverse").lower())
  ... )
  shape: (3, 4)
  ┌───────────┬───────────┬─────┬─────┐
  │ A_reverse ┆ B_reverse ┆ a   ┆ b   │
  │ ---       ┆ ---       ┆ --- ┆ --- │
  │ i64       ┆ str       ┆ i64 ┆ str │
  ╞═══════════╪═══════════╪═════╪═════╡
  │ 3         ┆ z         ┆ 1   ┆ x   │
  │ 2         ┆ y         ┆ 2   ┆ y   │
  │ 1         ┆ x         ┆ 3   ┆ z   │
  └───────────┴───────────┴─────┴─────┘
docstr_tok: ["Rename","the","output","of","an","expression","by","mapping","a","function","over","the","root","name",".","Parameters","--","--","--","--","--","function","Function","that","maps","a","root","name","to","a","new","name",".","See","Also","--","--","--","--","keep","prefix","suffix","Examples","--","--","--","--","Remove","a","common","suffix","and","convert","to","lower","case",".",">",">",">","df","=","pl.DataFrame","(","...","{","...","``","A_reverse","''",":","[","3",",","2",",","1","]",",","...","``","B_reverse","''",":","[","``","z","''",",","``","y","''",",","``","x","''","]",",","...","}","...",")",">",">",">","df.with_columns","(","...","pl.all","(",")",".reverse","(",")",".name.map","(","lambda","c",":","c.rstrip","(","``","_reverse","''",")",".lower","(",")",")","...",")","shape",":","(","3",",","4",")","\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2510","\u2502","A_reverse","\u2506","B_reverse","\u2506","a","\u2506","b","\u2502","\u2502","--","-","\u2506","--","-","\u2506","--","-","\u2506","--","-","\u2502","\u2502","i64","\u2506","str","\u2506","i64","\u2506","str","\u2502","\u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2561","\u2502","3","\u2506","z","\u2506","1","\u2506","x","\u2502","\u2502","2","\u2506","y","\u2506","2","\u2506","y","\u2502","\u2502","1","\u2506","x","\u2506","3","\u2506","z","\u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2518"]
code: def map(self, function: Callable[[str], str]) -> Expr:
      """
      Rename the output of an expression by mapping a function over the root name.
  
      Parameters
      ----------
      function
          Function that maps a root name to a new name.
  
      See Also
      --------
      keep
      prefix
      suffix
  
      Examples
      --------
      Remove a common suffix and convert to lower case.
  
      >>> df = pl.DataFrame(
      ...     {
      ...         "A_reverse": [3, 2, 1],
      ...         "B_reverse": ["z", "y", "x"],
      ...     }
      ... )
      >>> df.with_columns(
      ...     pl.all().reverse().name.map(lambda c: c.rstrip("_reverse").lower())
      ... )
      shape: (3, 4)
      ┌───────────┬───────────┬─────┬─────┐
      │ A_reverse ┆ B_reverse ┆ a   ┆ b   │
      │ ---       ┆ ---       ┆ --- ┆ --- │
      │ i64       ┆ str       ┆ i64 ┆ str │
      ╞═══════════╪═══════════╪═════╪═════╡
      │ 3         ┆ z         ┆ 1   ┆ x   │
      │ 2         ┆ y         ┆ 2   ┆ y   │
      │ 1         ┆ x         ┆ 3   ┆ z   │
      └───────────┴───────────┴─────┴─────┘
  
      """
      return self._from_pyexpr(self._pyexpr.name_map(function))
  
file_path: polars/py-polars/polars/expr/name.py
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Callable
label_desc: Use image node_id 3 for calling the ExprNameNameSpace obj's underlying member method code with example usage: obj.map(function) and returns: self