how to add new field in a 'zip' jagged array #2017
-
Hi experts, 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:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
The syntax you are describing ( If you have an array muons = ak.zip({
"pt": arrays["Muon_pt"],
"eta": arrays["Muon_eta"],
"phi": arrays["Muon_phi"],
"charge": arrays["Muon_charge"],
}) then you can assign a new/existing field with muons['pt'] = ... where This might fail if the expression cannot be broadcast against the existing array. |
Beta Was this translation helpful? Give feedback.
The syntax you are describing (
muons.Muon['2pt'] = 2 * arrays['Muon_pt"]
) is not quite right for assigning to an array. It also doesn't match up with themuons
array that you've defined above, so I will assume it's a typing mistake?If you have an array
muons
defined asthen you can assign a new/existing field with
where
...
is a Python expression.This might fail if the expression cannot be broadcast against the existing array.