Skip to content

Tmap

flowtask.components.tMap

tMap.

Making Column Transformations using a Mapping JSON file.

functions

tMap Transformations functions based on Series.

concat

concat(df, columns, sep=' ')

Concatenates the values of the specified columns in the given DataFrame.

:param df: The input DataFrame :param columns: The list of columns to concatenate :param sep: The separator to use between the concatenated values (default is a space) :return: A Series with the concatenated values

to_integer

to_integer(series, **kwargs)

Converts a pandas Series to an integer type, handling errors by coercing invalid values to NaN.

:param series: The pandas Series to be converted. :param kwargs: Additional keyword arguments. :return: The converted pandas Series with integer type.

to_string

to_string(series, remove_nan=False, **kwargs)

to_string.

Converting to string a Pandas column (Series) Args: series (pandas.Series): Column Series to be converted remove_nan (bool, optional): remove Not a Number from Column. Defaults to False.

Returns:

Type Description
Series

pandas.Series: a New Serie is returned with string values.

tMap

tMap

tMap(loop=None, job=None, stat=None, **kwargs)

Bases: FlowComponent

tMap

Overview

The tMap class is a component for transforming and mapping data in a Pandas DataFrame. It supports various column name
transformations, data type conversions, and function applications to columns. It extends the FlowComponent class and
provides methods for column information retrieval, data transformation, and function execution.

.. table:: Properties :widths: auto

+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| Name             | Required | Description                                                                                      |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| tablename        |   No     | The name of the table to retrieve column information from.                                       |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| schema           |   No     | The schema of the table to retrieve column information from.                                     |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| model            |   No     | The model to use for data transformation.                                                        |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| _modelinfo       |   No     | A dictionary containing the model information.                                                   |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| map              |   No     | The map file to use for column transformations.                                                  |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| _mapping         |   No     | A dictionary containing the column mappings.                                                     |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| force_map        |   No     | A flag indicating if the map file should be forced, defaults to False.                           |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| replace_columns  |   No     | A flag indicating if columns should be replaced, defaults to True.                               |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| drop_missing     |   No     | A flag indicating if missing columns should be dropped, defaults to False.                       |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
|  column_info     |   Yes    | I access the information of the column through a statement in sql to extract the data            |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
|  clean_names     |   Yes    | Remove duplicate names from data                                                                 |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+

Return

The methods in this class manage the transformation and mapping of data in a Pandas DataFrame, including initialization,
column information retrieval, data transformation, and function execution.



Example:

```yaml
tMap:
  schema: bose
  map: products_by_store
  drop_missing: false
```
close async
close()

close.

close method
run async
run()

run.

Iteration over all dataframes.