Columns
- class rolumns.Columns(cursor: Optional[Union[Cursor, Group, str]] = None)[source]
A set of columns.
from rolumns import Columns data = [ { "name": "Robert Pringles", "email": "bob@pringles.pop", }, ] columns = Columns() columns.add("Name", "name") columns.add("Email", "email")
- add(name: str, source: Optional[Union[Source, str]] = None) None [source]
Adds a column.
source describes the data source for the column, which can be:
an explicit
Source
a string that describes the
.
-separated path to the valueNone if this set’s record is an iterable list of primitives
from rolumns import Columns, Source data = [ { "name": "Robert Pringles", "email": "bob@pringles.pop", "awards": [ "Fastest Doughnut Run", "Tie of the Year", ], }, ] columns = Columns() columns.add("Name", "name") columns.add("Email", Source(path="email")) awards = columns.group("awards") # "awards" is also a column set awards.add("Awards")
- group(cursor: Union[Cursor, Group, str]) Columns [source]
Creates and adds a grouped column set.
A column set cannot have multiple groups (though each group can have its own group). Will raise
exceptions.MultipleGroups
if you try to add a second group.from rolumns import Columns, Source data = [ { "name": "Robert Pringles", "awards": [ "Fastest Doughnut Run", "Tie of the Year", ], }, ] columns = Columns() columns.add("Name", "name") awards = columns.group("awards") awards.add("Awards")
- normalize() List[Dict[str, Any]] [source]
Normalises data into a list of dictionaries describing column names and values.