CharacterReplacer
Replace or remove a character or substring in all selected text columns.
Scans each value in the configured string columns and substitutes every
occurrence of char_to_replace with replacement_char. If the
replacement produces a column of pure integers, the column type is promoted
to Integer.
Parameters
- char_to_replace : string, default=
- The character or substring to be replaced. Cannot be empty.
- replacement_char, default=
None - The character or substring to replace with. If null, 'char_to_replace' will be removed.
Methods
changes_row_count(self) -> bool
CharacterReplacerReturn False because this converter never adds or removes rows.
Returns
- bool
- Always
False.
fit(self, x: 'DashAIDataset', y: Optional[ForwardRef('DashAIDataset')] = None) -> 'CharacterReplacer'
CharacterReplacerIdentify which columns in x are of Text type.
Parameters
- x : DashAIDataset
- The dataset whose columns will be inspected.
- y : DashAIDataset, optional
- Ignored. Defaults to None.
Returns
- CharacterReplacer
- The fitted converter instance (self).
get_output_type(self, column_name: str = None) -> DashAI.back.types.dashai_data_type.DashAIDataType
CharacterReplacerReturn the default output type for a transformed column.
Parameters
- column_name : str, optional
- Not used. Defaults to None.
Returns
- DashAIDataType
- A Text type backed by
pyarrow.string().
transform(self, x: 'DashAIDataset', y: Optional[ForwardRef('DashAIDataset')] = None) -> 'DashAIDataset'
CharacterReplacerApply the character replacement to the fitted text columns.
Parameters
- x : DashAIDataset
- The dataset to transform.
- y : DashAIDataset, optional
- Ignored. Defaults to None.
Returns
- DashAIDataset
- A new dataset with
char_to_replacesubstituted in all text columns. If replacement yields only integer-like values, the column type is promoted toInteger.
get_metadata(cls) -> 'Dict[str, Any]'
BaseConverterGet metadata for the converter, used by the DashAI frontend.
Parameters
- cls : type
- The converter class (injected automatically by Python for classmethods).
Returns
- Dict[str, Any]
- Dictionary containing display name, short description, image preview path, category, icon, color, and whether the converter is supervised.
get_schema(cls) -> dict
ConfigObjectGenerates the component related Json Schema.
Returns
- dict
- Dictionary representing the Json Schema of the component.
validate_and_transform(self, raw_data: dict) -> dict
ConfigObjectIt takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.
Parameters
- raw_data : dict
- A dictionary with the data provided by the user to initialize the model.
Returns
- dict
- A validated dictionary with the necessary objects.