MCPcopy Index your code
hub / github.com/pathwaycom/pathway / rename

Method rename

python/pathway/internals/table.py:2147–2167  ·  view source on GitHub ↗

Rename columns according either a dictionary or kwargs. If a mapping is provided using a dictionary, ``rename_by_dict`` will be used. Otherwise, ``rename_columns`` will be used with kwargs. Columns not in keys(kwargs) are not changed. New name of a column must not be ``id``.

(
        self,
        names_mapping: dict[str | expr.ColumnReference, str] | None = None,
        **kwargs: expr.ColumnExpression,
    )

Source from the content-addressed store, hash-verified

2145 @trace_user_frame
2146 @check_arg_types
2147 def rename(
2148 self,
2149 names_mapping: dict[str | expr.ColumnReference, str] | None = None,
2150 **kwargs: expr.ColumnExpression,
2151 ) -> Table:
2152 """Rename columns according either a dictionary or kwargs.
2153
2154 If a mapping is provided using a dictionary, ``rename_by_dict`` will be used.
2155 Otherwise, ``rename_columns`` will be used with kwargs.
2156 Columns not in keys(kwargs) are not changed. New name of a column must not be ``id``.
2157
2158 Args:
2159 names_mapping: mapping from old column names to new names.
2160 kwargs: mapping from old column names to new names.
2161
2162 Returns:
2163 Table: `self` with columns renamed.
2164 """
2165 if names_mapping is not None:
2166 return self.rename_by_dict(names_mapping=names_mapping)
2167 return self.rename_columns(**kwargs)
2168
2169 @trace_user_frame
2170 @desugar

Callers 10

diffFunction · 0.45
__call__Method · 0.45
test_rename_with_dictFunction · 0.45
test_rename_with_kwargsFunction · 0.45
test_slices_3Function · 0.45
test_slices_4Function · 0.45
test_slices_5Function · 0.45
test_slices_1Function · 0.45
test_no_columns_addedFunction · 0.45

Calls 2

rename_by_dictMethod · 0.95
rename_columnsMethod · 0.95

Tested by 8

test_rename_with_dictFunction · 0.36
test_rename_with_kwargsFunction · 0.36
test_slices_3Function · 0.36
test_slices_4Function · 0.36
test_slices_5Function · 0.36
test_slices_1Function · 0.36
test_no_columns_addedFunction · 0.36