DimensionRecordTable¶
- final class lsst.daf.butler.DimensionRecordTable(element: DimensionElement | str | None = None, records: Iterable[DimensionRecord] = (), universe: DimensionUniverse | None = None, table: pa.Table | None = None, batch_size: int | None = None)¶
Bases:
objectA table-like container for
DimensionRecordobjects.- Parameters:
- element
DimensionElementorstr, optional The dimension element that defines the records held by this table. If not a
DimensionElementinstance,universemust be provided. If not provided,tablemust have an “element” entry in its metadata (as is the case for tables returned by theto_arrowmethod).- records
Iterable[DimensionRecord], optional Dimension records to add to the table.
- universe
DimensionUniverse, optional Object that defines all dimensions. Ignored if
elementis aDimensionElementinstance.- table
pyarrow.Table Arrow table to copy columns from. Must have schema returned by
make_arrow_schemafor this element. This argument is primarily intended to serve as the way to reconstruct aDimensionRecordTablethat has been serialized to an Arrow-supported file or IPC format.- batch_size
int, optional How many elements of
recordsshould be processed at a time, with each batch yielding apyarrow.RecordBatchin the created table. Smaller values will reduce peak memory usage for large iterables. Ignored ifrecordsis empty.
- element
Notes
DimensionRecordTableshould generally have a smaller memory footprint thanDimensionRecordSetif its rows are unique, and it provides fast column-oriented access and Arrow interoperability thatDimensionRecordSetlacks entirely. In other respectsDimensionRecordSetis more featureful and simpler to use efficiently.Attributes Summary
The dimension element that defines the records of this table.
Methods Summary
column(name)Return a single column from the table as an array.
extend(records)Add new rows to the end of the table.
make_arrow_schema(element)Return the Arrow schema of the table returned by
to_arrowwith the given dimension element.to_arrow()Return a Arrow table holding the same records.
Attributes Documentation
- element¶
The dimension element that defines the records of this table.
Methods Documentation
- column(name: str) ChunkedArray¶
Return a single column from the table as an array.
- Parameters:
- name
str Name of the column. Valid options are given by
DimensionElement.schema.names, and are the same as the attributes of the dimension records.
- name
- Returns:
- array
pyarrow.ChunkedArray An array view of the column.
- array
- extend(records: Iterable[DimensionRecord]) None¶
Add new rows to the end of the table.
- Parameters:
- records
Iterable[DimensionRecord] Dimension records to add to the table.
- records
- classmethod make_arrow_schema(element: DimensionElement) pa.Schema¶
Return the Arrow schema of the table returned by
to_arrowwith the given dimension element.- Parameters:
- element
DimensionElement Dimension element that defines the schema.
- element
- Returns:
- schema
pyarrow.Schema Arrow schema.
- schema
- to_arrow() Table¶
Return a Arrow table holding the same records.