Hi. I need to transform a python dictionary into a TTree. So far I’ve been using RDataFrames. I can do it succesfully with simple data structures (dict1D) via MakeNumpyDataFrame. But it fails when the data contains collections (dictND). I tried two (unsuccesful) methods based on this and this example.
Below I provide some simplified data with the same structure as my real case.
You can use TTree directly and create TTree branches that contain the arrays. There should be several posts on the forum on this topic, maybe @etejedor can point to a good example.
Hello, thank you for the suggestions. I started to work with ttree directly, but I was getting many errors and it felt like I was re-inventing the wheel. I’m looking forward for the implementation of Awkward Arrays with RDF!
So far I found a rather simple solution with uproot:
dictfull = {**dict1D, **dictND}
import awkward as ak
for key in dictfull:
dictfull[key] = ak.Array(dictfull[key])
import uproot
f = uproot.recreate("example.root")
f["tree"] = dictfull