Stacking and joining sources
Lynguine combines sources with hstack (side by side) and vstack
(one below the other). When several sources or flows share column names,
the join rule is explicit: earlier wins. Later colliding columns are
dropped rather than raising a pandas overlap error.
Horizontal stacking (hstack)
hstack aligns sources on a common key or index so each source
contributes columns for the same rows.
Required keys:
type:hstackspecifications: list of nested source blocks
Optional keys (defaults shown):
on: join key (defaultindex)how:left,right,outer, orinner(defaultleft)lsuffix: suffix for overlapping left columns (default empty)rsuffix: suffix for overlapping right columns (default_right)normalize: omit for case-sensitive keys (default). Setcasefoldon a right specification to match join keys with Unicode case folding while keeping the left side’s spelling (CIP-001C). Use only for identifier-like keys (for example CRSId or filesystem path stems). If two distinct keys on one side casefold to the same string, the join raises rather than dropping a row silently.
Two-way overlap keeps the left name and suffixes the right. A later source that would recreate an existing suffixed name is dropped.
type: hstack
specifications:
- type: csv
filename: data/people.csv
- type: excel
filename: data/scores.xlsx
sheet: Sheet1
on: id
how: left
Identifier joins that must ignore case (roster lowercase, filenames mixed case):
type: hstack
specifications:
- type: csv
filename: data/students.csv
- type: markdown_directory
source:
- directory: dialogues/
glob: "*.md"
index: crsid
how: left
normalize: casefold
Vertical stacking (vstack)
vstack concatenates sources that share a column set.
type:vstackspecifications: list of nested source blocksreset_index: reset after concat (defaultfalse)
You can nest hstack inside vstack (and the reverse).
Earlier-wins on overlapping columns
The same policy applies at two sites:
Site |
Behaviour |
|---|---|
|
Before |
|
Before |
Identity columns such as crsid or givenName often appear on more
than two sources. The first occurrence is kept. Later copies are not
suffixed again and are not merged in.
See lynguine.access.io.read_hstack() and
lynguine.assess.data.CustomDataFrame.to_pandas().
Column types and mappings are covered in
Column Management in CustomDataFrame.