I want to add a new field in an already zipped jagged array. For example, if I zip 4D info into a muons object, then I can call pt,eta,phi,charge like this: muons.Muon.pt. However, if I want to add a new field such as 2*pt into this muons object, then I can't do this with muons.Muon['pt2'] = 2 * arrays['Muon_pt"]. Is there anything I misunderstand or how can I add a new field in this jagged array? Could you please help me? thanks
muons = ak.zip({
"pt": arrays["Muon_pt"],
"eta": arrays["Muon_eta"],
"phi": arrays["Muon_phi"],
"charge": arrays["Muon_charge"],
})
I think I can add a new field in the zipped jagged array, like: muons.Muon['pt2'] then I can call this field with muons.Muon.pt2
What you've described is the right way to go about it, and it should work.
As a walkthrough, we first get some
arrays,Then zip them into a structure,
And now add the new field:
By construction, this
px2has the same number of elements (deeply, for all sublists) aspx. That should also be true in yourptexample. So the above line should successfully add the new field; if it doesn't, then I think you want to submit a bug report.Here's what the new
muonslooks like for me:px2has been added to the record type and you can see it in the values. This is Uproot 5 and Awkward Array 2, by the way, but this should also have worked in the previous major version.