Custom dictionary-like container for tabular equation data.
Dataframe maintains tabular structure where all rows have consistent column count. Used by show_eqn() to create multi-column LaTeX output where keys represent row labels in the amsmath block and values are lists that populate columns across each row.
The Dataframe can be initialized from a list of dicts (where each dict represents a column of data) or from a single dict (where values are lists representing rows).
Parameters
Name
Type
Description
Default
*args
Any
If first arg is list of dicts, initializes from column sequences. Otherwise, expects at most one dictionary for row-based initialization.
()
filler
Any
Value used to fill missing entries when sequences have different lengths. Defaults to None.
None
**kwargs
Any
Additional key-value pairs for initialization.
{}
Examples
from keecas import Dataframe, symbols, u# Initialize from list of dicts (column-based)F, A = symbols(r"F, A")_p = {F: 100*u.kN, A: 20*u.cm**2}_e = {F: "F_applied", A: "A_load"}df = Dataframe([_p, _e])df
Update the Dataframe with new data, extending width as needed.
Similar to dict.update() but maintains tabular structure by ensuring all columns have consistent length after the update.
Parameters
Name
Type
Description
Default
*args
Any
Positional arguments (expects at most one dictionary)
()
**kwargs
Any
Keyword arguments representing new column data
{}
Raises
Name
Type
Description
TypeError
If more than one positional argument is provided
append
append(other, strict=True)
Append a single column to the Dataframe.
Adds one new column to the right of existing columns. Each row receives either the corresponding value from ‘other’ or the filler value if not present.
Data to append as a new column. Can be: - Dataframe: Uses first column of the other Dataframe (index 0) - dict: Uses values from the dictionary matching existing row keys - Any: Uses the same value for all rows in the new column
required
strict
bool
If True, only considers keys that exist in self. When False, ignores extra keys in ‘other’. Defaults to True.
True
Examples
from keecas import Dataframe, symbols, uF, A = symbols(r"F, A")# Start with parametersdf = Dataframe({F: [100*u.kN], A: [20*u.cm**2]})# Append descriptions as new columndf.append({F: "applied force", A: "load area"})df
Data to extend with. Can be: - Dataframe: Adds all columns from the other Dataframe - dict: Converts to Dataframe and extends (values as lists for multiple columns) - list: Extends each row with the list values (all rows get same list)
required
strict
bool
If True, only considers row keys that exist in self. When False, new keys from ‘other’ are added as new rows. Defaults to True.
True
Raises
Name
Type
Description
ValueError
If other is not a supported type (Dataframe, dict, or list).
Examples
from keecas import Dataframe, symbols, u, pcF, A, sigma = symbols(r"F, A, \sigma")# Start with parameters_p = Dataframe({F: [100*u.kN], A: [20*u.cm**2]})# Extend with expressions and values_e = Dataframe({F: ["F"], A: ["A"], sigma: ["F/A"]})_v = Dataframe({sigma: [5*u.MPa]}, filler=None)_p.extend(_e)_p.extend(_v, strict=False) # Add new row sigma_p