tableserializer.table module
Submodules
tableserializer.table.preprocessor module
- class tableserializer.table.preprocessor.TablePreprocessor(apply_before_row_sampling: bool = False)[source]
Bases:
ABC,SignatureProvidingInstanceA table preprocessor transforms a table before serialization. Generally, table preprocessors can augment the tabular data, compress it (e.g., by removing id columns), …
- Parameters:
apply_before_row_sampling (bool) – Set to true to execute the preprocessor before the row sampling.
- class tableserializer.table.preprocessor.ColumnDroppingPreprocessor(columns_to_drop: List[str], apply_before_row_sampling=False)[source]
Bases:
TablePreprocessorTable preprocessor that transforms a table by dropping specified columns.
- Parameters:
columns_to_drop (List[str]) – List of column names of columns to drop.
apply_before_row_sampling (bool) – Set to true to execute the preprocessor before the row sampling.
- class tableserializer.table.preprocessor.StringTruncationPreprocessor(max_len: int, apply_before_row_sampling=False)[source]
Bases:
TablePreprocessorTable preprocessor that truncates strings in the table to a set maximum length before serialization.
- Parameters:
max_len (int) – Maximum length of strings for truncation.
apply_before_row_sampling (bool) – Set to true to execute the preprocessor before the row sampling.
tableserializer.table.row_sampler module
- class tableserializer.table.row_sampler.RowSampler(rows_to_sample: int = 10)[source]
Bases:
ABC,SignatureProvidingInstanceA row sampler selects a subset of rows based on a predefined policy.
- Parameters:
rows_to_sample (int) – Number of rows to sample.
- class tableserializer.table.row_sampler.RandomRowSampler(rows_to_sample: int = 10, deterministic: bool = True)[source]
Bases:
RowSamplerSamples rows randomly from the given table.
- Parameters:
rows_to_sample (int) – Number of rows to sample.
deterministic (bool) – Set to true to apply a deterministic seed for the sampling process. This ensures replicability.
- class tableserializer.table.row_sampler.FirstRowSampler(rows_to_sample: int = 10)[source]
Bases:
RowSamplerSample the first rows from the given table.
- Parameters:
rows_to_sample (int) – Number of rows to sample.
- class tableserializer.table.row_sampler.KMeansRowSampler(rows_to_sample: int = 10, deterministic: bool = True)[source]
Bases:
RowSamplerUse k-means clustering to sample a diverse set of rows.
- Parameters:
rows_to_sample (int) – Number of rows to sample.
deterministic (bool) – Set to true to apply a deterministic seed for the sampling process.
tableserializer.table.table module
- class tableserializer.table.table.Table(table_contents: DataFrame | List[Dict[str, str]] | List[List[str]])[source]
Bases:
objectRepresents the contents of a raw table.
- Parameters:
table_contents (Union[pd.DataFrame, List[Dict[str, str]], List[List[str]]]) – Table contents in one of the supported formats.
- as_list_of_lists() List[List[str]][source]
Get the table as a list of the lists.
- Returns:
Table as a list of the lists.
- Return type:
List[List[str]]