slitflow.tbl.convert module

class SortCols(info_path=None)[source]

Bases: Table

Change column depths and sort values.

If you want to change from [“img_no”, “trj_no”, “frm_no”] to [“frm_no”, “img_no”, “trj_no”], set new_depths = [2,3,1].

Parameters:
  • reqs[0] (Table) – Table for sorting.

  • param["new_depths"] (list of int) – Target depth number of indexes. If list length < total columns, remaining columns are assumed as depth=0.

  • param["split_depth"] (int) – File split depth number.

Returns:

Sorted Table

Return type:

Table

set_info(param={})[source]

Copy info from reqs[0] and change depths.

static process(reqs, param)[source]

Sort values of the table by column names.

Parameters:
Returns:

Sorted table

Return type:

pandas.DataFrame

class AddColumn(info_path=None)[source]

Bases: Table

Add new columns with explicit values to a table.

Caution

Do not split the input table. TODO: col_values should have the same length as the input table.

Parameters:
  • reqs[0] (Table) – The input table to add columns to.

  • param["col_info"] (list) – Information about the new column. The list should contain [depth, name, type, unit, description] or list of it.

  • param["col_values"] (list) – The values of the new column. The length of the list should be equal to the length of the “col_info” list.

  • param["split_depth"] (int) – The file split depth number.

Returns:

The table with the new column.

Return type:

Table

set_info(param={})[source]

Copy info from reqs[0] and add columns.

static process(reqs, param)[source]

Add new columns with explicit values to a table.

Parameters:
  • reqs[0] (pandas.DataFrame) – The input table to add columns to.

  • param["col_name"] (str) – The names of the columns to add.

  • param["col_values"] (list) – The values of the new column. The length of the list should be equal to the length of the “col_name” list.

Returns:

The table with the new column.

Return type:

pandas.DataFrame

class Obs2Depth(info_path=None)[source]

Bases: Table

Merge tables from different observations into a top level depth.

Caution

This class only works when used in a Pipeline object. Running process method or creating a Data object does not work appropriately.

Observation names for merging should be listed into obs_name argument of add() in Pipeline class.

Parameters:
  • reqs (list of Table) – Tables to merge.

  • param["col_name"] (str, optional) – New column name for observation numbers. Defaults to “obs_no”.

  • param["col_description"] (str, optional) – New column description. Defaults to “Observation number”.

  • param["obs_name"] (str) – New observation name.

  • param["split_depth"] (int) – File split depth number.

Returns:

Merged Table

Return type:

Table

set_info(param={})[source]

Copy info from reqs[0] and add parameters.

static process(reqs, param)[source]

Merge different Observations into the top level depth.

Parameters:
  • reqs (list of pandas.DataFrame) – Tables from different observations.

  • param["col_name"] (str, optional) – New column name for observation numbers.

Returns:

Merged table

Return type:

pandas.DataFrame