Uproot5
ROOT I/O in pure Python and NumPy.
Install / Use
/learn @scikit-hep/Uproot5README
Uproot is a library for reading and writing ROOT files in pure Python and NumPy.
Unlike the standard C++ ROOT implementation, Uproot is only an I/O library, primarily intended to stream data into machine learning libraries in Python. Unlike PyROOT and root_numpy, Uproot does not depend on C++ ROOT. Instead, it uses Numpy to cast blocks of data from the ROOT file as Numpy arrays.
<p align="center"><img src="https://raw.githubusercontent.com/scikit-hep/uproot5/main/docs-img/diagrams/abstraction-layers.svg" width="700px"></p>Installation
Uproot can be installed from PyPI using pip.
pip install uproot
Uproot is also available using conda.
conda install -c conda-forge uproot
If you have already added conda-forge as a channel, the -c conda-forge is unnecessary. Adding the channel is recommended because it ensures that all of your packages use compatible versions (see conda-forge docs):
conda config --add channels conda-forge
conda update --all
Getting help
Start with the tutorials and reference documentation.
- Report bugs, request features, and ask for additional documentation on GitHub Issues.
- If you have a "How do I...?" question, start a GitHub Discussion with category "Q&A".
- Alternatively, ask about it on StackOverflow with the [uproot] tag. Be sure to include tags for any other libraries that you use, such as Pandas or PyTorch.
- To ask questions in real time, try the Gitter Scikit-HEP/uproot chat room.
Installation for developers
Uproot is an ordinary Python library; you can get a copy of the code with
git clone https://github.com/scikit-hep/uproot5.git
and install it locally by calling pip install -e . in the repository directory.
If you need to develop Awkward Array as well, see its installation for developers.
Dependencies
Uproot's only strict dependencies are Awkward, Cramjam, xxhash, fsspec, NumPy, packaging. Strict dependencies are automatically installed by pip (or conda).
The following libraries are also useful in conjunction with Uproot, but are not necessary. If you call a function that needs one, you'll be prompted to install it. (Conda installs most of these automatically.)
For accessing remote files:
s3fs: if reading files withs3://URIs.xrootd: if reading files withroot://URIs.- HTTP/S access is built in (Python standard library).
For distributed computing with Dask:
dask: see uproot.dask.dask-awkward: for data with irregular structure ("jagged" arrays), see dask-awkward.
For exporting TTrees to Pandas:
pandas: iflibrary="pd".awkward-pandas: iflibrary="pd"and the data have irregular structure ("jagged" arrays), see awkward-pandas.
For exporting histograms:
boost-histogram: if converting histograms to boost-histogram withhistogram.to_boost().hist: if converting histograms to hist withhistogram.to_hist().
Acknowledgements
Support for this work was provided by NSF cooperative agreements OAC-1836650 and PHY-2323298 (IRIS-HEP), grant OAC-1450377 (DIANA/HEP), and PHY-2121686 (US-CMS LHC Ops).
Thanks especially to the gracious help of Uproot contributors (including the original repository).
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tbody> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/jpivarski"><img src="https://avatars0.githubusercontent.com/u/1852447?v=4?s=100" width="100px;" alt="Jim Pivarski"/><br /><sub><b>Jim Pivarski</b></sub></a><br /><a href="https://github.com/scikit-hep/uproot5/commits?author=jpivarski" title="Code">💻</a> <a href="https://github.com/scikit-hep/uproot5/commits?author=jpivarski" title="Documentation">📖</a> <a href="#infra-jpivarski" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-jpivarski" title="Maintenance">🚧</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/reikdas"><img src="https://avatars0.githubusercontent.com/u/11775615?v=4?s=100" width="100px;" alt="Pratyush Das"/><br /><sub><b>Pratyush Das</b></sub></a><br /><a href="https://github.com/scikit-hep/uproot5/commits?author=reikdas" title="Code">💻</a> <a href="#infra-reikdas" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/chrisburr"><img src="https://avatars3.githubusercontent.com/u/5220533?v=4?s=100" width="100px;" alt="Chris Burr"/><br /><sub><b>Chris Burr</b></sub></a><br /><a href="https://github.com/scikit-hep/uproot5/commits?author=chrisburr" title="Code">💻</a> <a href="#infra-chrisburr" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/plexoos"><img src="https://avatars0.githubusercontent.com/u/5005079?v=4?s=100" width="100px;" alt="Dmitri Smirnov"/><br /><sub><b>Dmitri Smirnov</b></sub></a><br /><a href="https://github.com/scikit-hep/uproot5/commits?author=plexoos" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="http://www.matthewfeickert.com/"><img src="https://avatars3.githubusercontent.com/u/5142394?v=4?s=100" width="100px;" alt="Matthew Feickert"/><br /><sub><b>Matthew Feickert</b></sub></a><br /><a href="#infra-matthewfeickert" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td> <td align="center" valign="top" width="14.28%"><a href="http://www.tamasgal.com"><img src="https://avatars1.githubusercontent.com/u/1730350?v=4?s=100" width="100px;" alt="Tamas Gal"/><br /><sub><b>Tamas Gal</b></sub></a><br /><a href="https://github.com/scikit-hep/uproot5/commits?author=tamasgal" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/kreczko"><img src="https://avatars3.githubusercontent.com/u/1213276?v=4?s=100" width="100px;" alt="Luke Kreczko"/><br /><sub><b>Luke Kreczko</b></sub></a><br /><a href="https://github.com/scikit-hep/uproot5/commits?author=kreczko" title="Code">💻</a> <a href="https://github.com/scikit-hep/uproot5/commits?author=kreczko" title="Tests">⚠️</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/nsmith-"><img src="https://avatars2.githubusercontent.com/u/6587412?v=4?s=100" width="100px;" alt="Nicholas Smith"/><br /><sub><b>Nicholas Smith</b></sub></a><br /><a href="https://github.com/scikit-hep/uproot5/commits?author=nsmith-" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/nbiederbeck"><img src="https://avatars1.githubusercontent.com/u/15156697?v=4?s=100" width="100px;" alt="Noah Biederbeck"/><br /><sub><b>Noah Biederbeck</b></sub></a><br /><a href="https://github.com/scikit-hep/uproot5/commits?author=nbiederbeck" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/oshadura"><img src="https://avatars2.githubusercontent.com/u/7012420?v=4?s=100" width="100px;" alt="Oksana Shadura"/><br /><sub><b>Oksana Shadura</b></sub></a><br /><a href="https://github.com/scikit-hep/uproot5/commits?author=oshadura" title="Code">💻</a> <a href="#infra-oshadura" tit