bach.DataFrame.rename

rename

(mapper=None, index=None, columns=None, axis=0, level=None, errors='ignore')

[source]

Rename columns.

The interface is similar to Panda’s pandas.DataFrame.rename(). However we don’t support renaming indexes, so recommended usage is rename(columns=...).

Parameters

  • mapper (Optional[Union[Dict[str, str], Callable[[str], str]]]) – dict to apply to that axis’ values. Use mapper and axis to specify the axis to target with mapper. Currently mapper is only supported with axis=1, which is similar to using columns.
  • index (Optional[Union[Dict[str, str], Callable[[str], str]]]) – not supported.
  • columns (Optional[Union[Dict[str, str], Callable[[str], str]]]) – dict str:str to rename columns, or a function that takes column names as an argument and returns the new one. The new column names must not clash with other column names in either self.data or self.index, after renaming is complete.
  • axis (int) – axis=1 is supported, rest is not.
  • level (Optional[int]) – not supported
  • errors (str) – Either ‘ignore’ or ‘raise’. When set to ‘ignore’ KeyErrors about non-existing column names in columns or mapper are ignored. Errors thrown in the mapper function or about invalid target column names are not suppressed.

Returns

DataFrame with the renamed axis labels.

Return type

bach.dataframe.DataFrame

note

The copy parameter is not supported since it makes very little sense for db backed series.