Saltar al contenido principal

CharacterReplacer

Converter
DashAI.back.converters.simple_converters.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. Every column keeps its type, even when the replacement leaves only digits: follow up with TypeCast to turn such a column into Integer. Deciding that from the values would make the output type depend on the data (and on each batch), so it could not be known before fitting.

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​

fit(self, x: 'DashAIDataset', y: Optional[ForwardRef('DashAIDataset')] = None) -> 'CharacterReplacer'

Defined on CharacterReplacer

Identify 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

Defined on CharacterReplacer

Return 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'

Defined on CharacterReplacer

Apply 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_replace substituted in all text columns, each keeping its type.

get_credential(self, name: str)

Defined on ConfigObject

Resolve a registered credential component by name.

Parameters

name : str
Credential component class name (e.g. "HuggingFaceCredential").

Returns

BaseCredential
An instance of the requested credential component.

get_metadata(cls) -> 'Dict[str, Any]'

Defined on BaseConverter

Get 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

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

infer_output_columns(self, inputs: 'List[StateItem]') -> 'StructureDelta'

Defined on BaseConverter

Estimate what this converter does to its scope, without any data.

Parameters

inputs : list of ColumnItem | BlockItem
The dataset state items in this converter's scope.

Returns

StructureDelta
The scope items that survive (maybe retyped) and the new items.

rows_to_keep(self, x: "'DashAIDataset'") -> 'List[int]'

Defined on BaseConverter

Positions of the rows of x that survive this converter.

Parameters

x : DashAIDataset
The converter's scope columns of one split.

Returns

list of int
0-based positions of the kept rows, in order.

validate_and_transform(self, raw_data: dict) -> dict

Defined on ConfigObject

It 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.