hepconvert.parquet_to_root

Defined in hepconvert.parquet_to_root on line 11.

hepconvert.parquet_to_root(destination, file, *, name='tree', force=False, branch_types=None, progress_bar=False, append=False, title='', field_name=<function <lambda>>, initial_basket_capacity=10, counter_name=<function <lambda>>, resize_factor=10.0, compression='ZLIB', compression_level=1)

Converts a Parquet file into a ROOT file. Data is stored in one TTree, which has a name defined by argument name.

Parameters:
  • destination (path-like) – Name of the output file or file path.

  • file (path-like) – Local parquet file to convert.

  • name (str, optional) – Name of tree to write to ROOT file (this will be the key to access the tree in the ROOT file). Defaults to “tree”. Command line option: --name.

  • branch_types (dict or pairs of str → NumPy dtype/Awkward type, optional) – Name and type specification for the TBranches. Defaults to None. Command line option: --branch-types.

  • title (str, optional) – Title for new TTree. Defaults to “”. Command line option: --title.

  • field_name (callable of str → str, optional) – Function to generate TBranch names for columns of an Awkward record array or a Pandas DataFrame.

  • initial_basket_capacity (int, optional) – Number of TBaskets that can be written to the TTree without rewriting the TTree metadata to make room. Command line option: --initial-basket-capacity.

  • resize_factor (float, optional) – When the TTree metadata needs to be rewritten, this specifies how many more TBasket slots to allocate as a multiplicative factor. Command line option: --resize-factor.

  • compression (str, optional) – Sets compression level for root file to write to. Can be one of “ZLIB”, “LZMA”, “LZ4”, or “ZSTD”. Defaults to “zlib”. Command line option: --compression.

  • compression_level (int, optional) – Use a compression level particular to the chosen compressor. Defaults to 1. Command line option: --compression-level.

  • force (boolean, optional) – If True, overwrites destination file if it exists. Command line option: --force.

Example:

>>> hepconvert.parquet_to_root("file.root", "file.parquet", name="tree")
>>> f = uproot.open("file.root")
>>> data = f["tree"]

Command Line Instructions:

This function can be run from the command line. Use command

hepconvert parquet-to-root [options] [OUT_FILE] [IN_FILE]