Relational data
RelationalData
RelationalData(data: Data, schema: Schema)
Relational data structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Data
|
A dictionary with table names as keys and |
required |
schema
|
Schema
|
A |
required |
select
select(
idx: dict[str, Sequence[Sequence[int]]],
reset_index: bool = False,
) -> list[RelationalData]
Select subsets of the input data according to the given indices for each root table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
dict[str, Sequence[Sequence[int]]]
|
A dictionary containing for each root table (except LUTs) the indices relative to each selection. |
required |
reset_index
|
bool
|
Whether to reset the index of the resulting dataframes. |
False
|
Returns:
| Type | Description |
|---|---|
list[RelationalData]
|
A list containing the selections. |
split
split(
ratio: float | int | dict[str, float | int],
reset_index: bool = False,
rng: NpRng = None,
) -> tuple[RelationalData, RelationalData]
Split the input data according to the given ratios for each root table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ratio
|
float | int | dict[str, float | int]
|
Split ratio. If a float, it must be between 0 and 1. If an integer > 1, then it is interpreted as the number of rows. If a dictionary, it must contain a split ratio for each root table (except LUTs). |
required |
reset_index
|
bool
|
Whether to reset the index of the resulting dataframes. |
False
|
rng
|
NpRng
|
Random state. If an int, it will be used as seed, if None the seed will be chosen randomly. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[RelationalData, RelationalData]
|
A tuple with the two splits. |
reset_keys
reset_keys(
start: dict[str, int] | None = None,
tables: Collection[str] | None = None,
) -> RelationalData
Reset the keys of the RelationalData object. Each resulting pd.DataFrame will have
a unique, incremental integer index as its primary key. Primary keys of LookupTable's
(and the foreign keys referring to them) are not changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
dict[str, int] | None
|
A dictionary with the starting values for the primary key of each table. If a table is not present, the default is 0. |
None
|
tables
|
Collection[str] | None
|
The tables for which to reset the primary keys. The foreign keys in the other tables referring to this set of primary keys will be refactored accordingly. By default, all keys are reset. |
None
|
Returns:
| Type | Description |
|---|---|
RelationalData
|
The |
concat
classmethod
concat(
*data: RelationalData,
reset_keys: bool | Collection[str] = False,
) -> RelationalData
Concatenate several instances of RelationalData with the same Schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*data
|
RelationalData
|
The |
()
|
reset_keys
|
bool | Collection[str]
|
Whether to reset the keys of the resulting |
False
|
Returns:
| Type | Description |
|---|---|
RelationalData
|
The concatenated |