tabled.multi#

Multi-tabled data structures.

Functions

columns_of_all_tables(tables)

Return all columns from all tables, in order of first appearance.

columns_of_first_table(tables)

Return the column names of the first table in tables.

dataframes(tables)

Cast to an iterable of dataframes.

execute_commands(commands, scope, ...[, ...])

Carries commands operations out with tables taken from scope.

execute_table_commands(commands, tables[, ...])

Run commands (Load/Join/Remove/Rename) against tables; see execute_commands.

join_func(scope, command)

Interpreter for Join: inner-merge the table at command.table_key into scope["cumul"].

load_func(scope, command)

Interpreter for Load: set scope["cumul"] to scope[command.key].

mapping_of_dataframes(tables)

Cast to a mapping of dataframes

remove_func(scope, command)

Interpreter for Remove: drop command.fields from scope["cumul"].

rename_func(scope, command)

Interpreter for Rename: rename scope["cumul"] columns and record the mapping in scope.

set_scope_value(scope, key, value)

Set scope[key] = value (in place).

Classes

ColumnOrientedMapping(tables[, columns])

A {column_name: concatenated_column_values} view over several tables.

Join(table_key)

Command: inner-join the accumulator with the table at scope[table_key].

Load(key)

Command: set the accumulator (scope["cumul"]) to scope[key].

Remove(fields)

Command: drop fields (column or columns) from the accumulator.

Rename(rename_mapping)

Command: rename accumulator columns per rename_mapping (old name -> new name).

class tabled.multi.ColumnOrientedMapping(tables, columns=<function columns_of_first_table>)[source]#

Bases: Mapping

A {column_name: concatenated_column_values} view over several tables.

Keys are column names (by default, the columns of the first table); each value is that column concatenated across all tables.

array(columns=None)[source]#

Concatenate a single column from all tables into one array.

columns must be a single column name (not a list): .df(columns) then has to return a Series (not a DataFrame) for .array to work.

property columns#

The columns that will be used in this mapping (the keys of the mapping)

columns_of_all_tables()#

Return all columns from all tables, in order of first appearance. This is useful for making a ColumnOrientedMapping without reverting to the default columns argument, which is to use the columns of the first table.

Return type:

Iterable[Column]

columns_of_first_table()#

Return the column names of the first table in tables.

Return type:

Iterable[Column]

df(columns=None)[source]#

Concatenate the given columns (all columns by default) from all tables into one dataframe.

class tabled.multi.Join(table_key)[source]#

Bases: object

Command: inner-join the accumulator with the table at scope[table_key].

class tabled.multi.Load(key)[source]#

Bases: object

Command: set the accumulator (scope["cumul"]) to scope[key].

class tabled.multi.Remove(fields)[source]#

Bases: object

Command: drop fields (column or columns) from the accumulator.

class tabled.multi.Rename(rename_mapping)[source]#

Bases: object

Command: rename accumulator columns per rename_mapping (old name -> new name).

tabled.multi.columns_of_all_tables(tables)[source]#

Return all columns from all tables, in order of first appearance. This is useful for making a ColumnOrientedMapping without reverting to the default columns argument, which is to use the columns of the first table.

Return type:

Iterable[Column]

tabled.multi.columns_of_first_table(tables)[source]#

Return the column names of the first table in tables.

Return type:

Iterable[Column]

tabled.multi.dataframes(tables)[source]#

Cast to an iterable of dataframes.

Return type:

Iterable[DataFrame]

tabled.multi.execute_commands(commands, scope, interpreter_map, *, extra_scope=None)[source]#

Carries commands operations out with tables taken from scope.

Parameters:

commands (Iterable) – An iterable of join operations to carry out.

tabled.multi.execute_table_commands(commands, tables, interpreter_map={<class 'tabled.multi.Join'>: <function join_func>, <class 'tabled.multi.Load'>: <function load_func>, <class 'tabled.multi.Remove'>: <function remove_func>, <class 'tabled.multi.Rename'>: <function rename_func>}, *, extra_scope=None)[source]#

Run commands (Load/Join/Remove/Rename) against tables; see execute_commands.

tabled.multi.join_func(scope, command)[source]#

Interpreter for Join: inner-merge the table at command.table_key into scope["cumul"].

If scope["renamed_columns"] was set by a prior Rename, that column renaming is applied to the joined table first, so a later rename stays consistent across joins.

Return type:

None

tabled.multi.load_func(scope, command)[source]#

Interpreter for Load: set scope["cumul"] to scope[command.key].

tabled.multi.mapping_of_dataframes(tables)[source]#

Cast to a mapping of dataframes

Return type:

Mapping[KT, DataFrame]

tabled.multi.remove_func(scope, command)[source]#

Interpreter for Remove: drop command.fields from scope["cumul"].

Return type:

None

tabled.multi.rename_func(scope, command)[source]#

Interpreter for Rename: rename scope["cumul"] columns and record the mapping in scope.

Return type:

None

tabled.multi.set_scope_value(scope, key, value)[source]#

Set scope[key] = value (in place).

Return type:

None