Skip to content

A Python module for conveniently loading/saving ROOT files as pandas DataFrames

License

Notifications You must be signed in to change notification settings

maxnoe/root_pandas

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

root_pandas

A convenience wrapper around the root_numpy library that allows you to load and save pandas DataFrames in the ROOT format used in high energy phyics.

from pandas import DataFrame
from root_pandas import read_root

df = DataFrame({'x1': [1, 2, 3], 'x2': [4, 5, 6]})

df.to_root('test.root', 'tree')

df_new = read_root('test.root', 'tree', ignore=['*1'])

# DataFrames are extremely convenient
df_new['answer'] = 42

df_new.to_root('new.root')
# The file contains a tree called 'default' with the 'x2' and 'answer' branches

There is also support for working with files that don't fit into memory: If the chunksize parameter is specified, read_root returns an iterator that yields DataFrames, each containing up to chunksize rows.

for df in read_root('bigfile.root', 'tree', chunksize=100000):
    # process df here
    df.to_root('finished.root')

By default, to_root appends to the output file.

Installation

The package is currently not on PyPI. To install it into your home directory with pip, run

pip install --user git+https://github.com/ibab/root_pandas

About

A Python module for conveniently loading/saving ROOT files as pandas DataFrames

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%