transpose#

swordfish.function.transpose()#

This function is used to transpose X:

  • If X is a tuple: return a tuple of the same length as each element of X. The n-th element of the result is a vector composed of the n-th element of each element of X.

  • If X is a matrix: return the transpose of X.

  • If X is a table: convert X into an ordered dictionary. The dictionary keys are column names. Each dictionary value is a vector of the corresponding column.

  • If X is a dictionary: convert X into a table. The dictionary keys must be of STRING type:

    • When values are scalars or vectors of equal length, the keys of X serve as the column names and the cooresponding values populate the column values in the table.

    • When the values are dictionaries, the resulting table will have the keys of X as the first column (named “key”). Subsequent columns will be derived from the keys of the first sub-dictionary with each row populated by corresponding values from all nested dictionaries. Missing keys in any sub-dictionary will result in null values in the table.

Note

Dictionaries with more than 32,767 keys cannot be converted into a table.

  • If X is an array vector or columnar tuple: switch data from columns to rows, or vice versa.

Parameters:

obj (Constant) –

A tuple/matrix/table/dictionary/array vector/columnar tuple.

  • If X is a tuple, all elements must be vectors of the same length.

  • If X is an array vector or columnar tuple, the number of elements in each row must be the same.