-
Notifications
You must be signed in to change notification settings - Fork 67
Convert a table into a dict of Jagged arrays #378
Comments
You can do this: {n: a[n] for n in a.columns} for some jagged array There are also |
It worked, thanks! |
If I remember right, ufuncs applied to a MaskedArray are only computed for the unmasked elements. They're less often used than jagged arrays and tables, but @nsmith- has had some success with them. |
For example, this emits no import awkward, numpy as np
a = np.random.normal(size=100)
ma = awkward.MaskedArray(a<0, a)
np.sqrt(ma) However, it copies the (valid subset) array under-the-hood. An old issue is to use the (somewhat new) numpy ufunc where argument: scikit-hep/awkward-0.x#110 |
I think this is done and can be closed. Let me know if I'm wrong! |
This issue is mainly a question.
I would like to know how I can convert a table
obtained with this code
uproot.open(root_filename)[tree].lazyarrays()
into a dict of Jagged arrays
obtained normally with this code
uproot.open(root_filename)[tree].arrays()
.This is because I would like to consider a table, compute a function that produces a mask (a vector of True or False with length equal to the number of rows of the table), and then create a dict of Jagged arrays without the masked rows.
This is because I need to run functions that would produce new jagged arrays (or new columns, if we think about tables), which are not applicable on all rows but only on those for which the mask is True.
Additionally, I also realised that executing operations with the dict of arrays is faster than with the table, is it expected?
The text was updated successfully, but these errors were encountered: