colstore.to_root¶
- colstore.to_root(source, path, *, backend='auto', treename='events', columns=None, batch_size='512 MiB', compression_level=0, compression_algorithm=None, output_format=None, multithreading=True, show_progress=True)[source]¶
Write a colstore reader, dataset, or selection out to a ROOT file.
The columns are streamed to
pathin bounded memory, onebatch_sizebatch at a time, so a store larger than memory writes fine. Column names that are not valid ROOT branch names (containing spaces, brackets, or other symbols) are reduced to word characters first, with a warning naming each change; colliding results are disambiguated with a numeric suffix.- Parameters:
source (colstore reader or dataset, str, or os.PathLike) – An opened reader or dataset, or a path to a
.cstorefile.path (str or os.PathLike) – Destination
.rootfile; recreated if it already exists.backend (str, optional) – Backend to write with:
"auto"(default) uses PyROOT if importable, else uproot;"ROOT"forces PyROOT/RDataFrame;"uproot"forces uproot. Raises if the requested backend is missing.treename (str, optional) – Name of the tree to write. Defaults to
"events".columns (list[str] or None, optional) – Columns to write, in this order.
None(default) writes every column. Naming a column absent from the store is an error.batch_size (int, str, or None, optional) – Per-batch memory budget: an
intis rows per batch; astr(default"512 MiB") is a byte budget;Nonewrites in a single pass.compression_level (int) – ROOT-backend options (ignored by the uproot backend).
compression_leveldefaults to0(uncompressed; ROOT’s own default is 5). The stringcompression_algorithm("zlib"/"lzma"/"lz4"/"zstd") andoutput_format("default"/"ttree"/"rntuple") name ROOT enums; any other value is passed through.multithreadingtoggles implicit MT for the Snapshot (anintsets the thread count), restored afterward; MT may reorder rows, so passFalseto preserve order.compression_algorithm (str | int | None) – ROOT-backend options (ignored by the uproot backend).
compression_leveldefaults to0(uncompressed; ROOT’s own default is 5). The stringcompression_algorithm("zlib"/"lzma"/"lz4"/"zstd") andoutput_format("default"/"ttree"/"rntuple") name ROOT enums; any other value is passed through.multithreadingtoggles implicit MT for the Snapshot (anintsets the thread count), restored afterward; MT may reorder rows, so passFalseto preserve order.output_format (str | int | None) – ROOT-backend options (ignored by the uproot backend).
compression_leveldefaults to0(uncompressed; ROOT’s own default is 5). The stringcompression_algorithm("zlib"/"lzma"/"lz4"/"zstd") andoutput_format("default"/"ttree"/"rntuple") name ROOT enums; any other value is passed through.multithreadingtoggles implicit MT for the Snapshot (anintsets the thread count), restored afterward; MT may reorder rows, so passFalseto preserve order.multithreading (bool | int) – ROOT-backend options (ignored by the uproot backend).
compression_leveldefaults to0(uncompressed; ROOT’s own default is 5). The stringcompression_algorithm("zlib"/"lzma"/"lz4"/"zstd") andoutput_format("default"/"ttree"/"rntuple") name ROOT enums; any other value is passed through.multithreadingtoggles implicit MT for the Snapshot (anintsets the thread count), restored afterward; MT may reorder rows, so passFalseto preserve order.show_progress (bool, optional) – Whether to display a progress bar. Defaults to True.
- Returns:
pathlib.Path – The path the ROOT file was written to.
- Return type: