Guide to Analyzing Data with Uproot and Pandas in Python

Slide Note
Embed
Share

Learn how to manipulate and analyze data from .root files using Uproot in Python. This tutorial covers installing Uproot, flattening jagged arrays, iterating through data, and working with Pandas dataframes for in-depth analysis, debugging, and visualization.


Uploaded on Jul 15, 2024 | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Uproot & Pandas Tutorial September 15, 2021 Robinpreet Dhillon 1

  2. Basics of uproot Install uproot using pip or conda. Allows us to work with .root files in Python. Using uproot to open files, we can see the data contained within. 2

  3. Must flatten jagged arrays to plot. Once flattened, we can carry out regular mathematical operations for each data point. Use the Awkward package: import awkward as ak 3

  4. 4

  5. uproot.iterate and pandas dataframes When determining the energy deposition of various particles and their corresponding energy resolutions, there are two paths: 1. Iterating through portions of entries of a file s Ttree using uproot.iterate 2. Creating a pandas dataframe(which can be viewed at any time for debugging) for the analysis. 5

  6. 6

  7. Instead, we can extract the desired data and save it to a pandas dataframe. 7

  8. 8

  9. Advantage over uproot.iterate is that we can see every column and debug as required. We can also extract specific columns; simply specify the column as shown: Now, we can simply pass the complete dataframe to the ProcessFiles function for the same analysis. 9

  10. To calculate the energy deposition in any ECAL component, use the [dataframe].apply operation: dataframe.apply(function, row) Applies the desired function to each row of the dataframe and returns the result. The results are then saved in the output array of choice for further use (plotting, fitting for energy resolutions, and more). 10

  11. 11

  12. 12

  13. Energy Resolutions of various particles 13

  14. 14

  15. 15

  16. Thanks for listening! 16

Related


More Related Content