Replies: 2 comments 3 replies
-
You're right: there isn't an operation for that! There are a lot of ways to slice rows within rows, but this is a column within a column. Perhaps the following my_array[["Muon_pt_1", "Muon_pt_2", "Electron_pt_1", "Electron_pt_2"], "Up"] should be defined in such a way as to select the inner field another_array[:, 1] for rows. It could be implemented here: Instead of applying the So it could be done and it could be a new feature that you can request. The hard part is figuring out how to do the deprecation cycle: if people are relying on the current behavior, how do tell them that it's going to change so that they can fix their scripts? Usually, new features are new function names or argument names, so they can't break any old code. When I want to change a named function or argument, I usually have to come up with a new name, so that the new name does the new thing and the old name has a deprecation warning and is eventually removed. (For example, renaming This
That's not as nice as introducing a new name that people can use now, and it certainly doesn't help your short term problem of how to do it in your analysis. To do it now, you have to do it longhand: ak.zip({field: my_array[field, "Up"] for field in ak.fields(my_array) if "Up" in ak.fields(my_array[field])}) (Note: the above would run in constant time, independent of the size of About the [x for x in ak.fields(my_array) if "Up" in ak.fields(my_array[x])] But I'd like to keep this Discussion open in case there's a lot of interest in the my_array[["Muon_pt_1", "Muon_pt_2", "Electron_pt_1", "Electron_pt_2"], "Up"] selector. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the detailed answer. |
Beta Was this translation helpful? Give feedback.
-
Hi,
first of all, thank you for the awesome job you're doing. I recently started using Awkward and I find it suitable and easy to use for most of the operations I usually perform during analysis.
I have a question regarding the possibility to get substructures from complex arrays.
Let's say I have an array whose type is the following:
Is there a simple way to get an array containing e.g. all the
Up
values from the fields that have it?Something like
I took a look at the documentation but I wasn't able to find anything like this. Sorry if it's there and I missed it.
Thank you,
Massimiliano
Beta Was this translation helpful? Give feedback.
All reactions