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]

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] (pandas.DataFrame) – 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.

Returns:

Sorted table

Return type:

pandas.DataFrame

class AddColumn(info_path=None)[source]

Bases: Table

Add a new column with values.

Caution

Do not split the required table.

Parameters:
  • reqs[0] (Table) – Table to add column.

  • param["col_info"] (list) – Information of new column. The list should be [depth, name, type, unit, description]

  • param["col_values"] (array-like) – Value list of new column.

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

Returns:

Column-added Table

Return type:

Table

set_info(param={})[source]

Copy info from reqs[0] and add column.

static process(reqs, param)[source]

Add a new column with values.

Parameters:
  • reqs[0] (pandas.DataFrame) – Table to add column.

  • param["col_values"] (array-like) – Value list of new column.

  • param["col_name"] (str) – New column name.

Returns:

Column-added table

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) – 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