Skip to content

Iterate over two trees (with same entries numbering) over many files ? #545

Answered by jpivarski
aphecetche asked this question in Q&A
Discussion options

You must be logged in to vote

Since the two trees are aligned by construction and you don't have to match values of one of TTree A's branches with one of TTree B's branches (as a JOIN key, as in SQL), then you can just use Python's zip. I was about to say "itertools.izip" because you absolutely want the two uproot.iterate iterators to be evaluated lazily through the iteration (so the memory use doesn't explode), but I'm behind the times: Python 3's built-in zip does that.

Iteration goes over batches of data, not individual entries, so the main thing is that you'll want both uproot.iterate iterators to give you the same number of entries in every batch. You can do that by passing an integer to step_size (see documentation

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aphecetche
Comment options

Answer selected by aphecetche
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants