Read data from Numpy arrays into RDataFrame.
import ROOT
import numpy as np
x = np.array([1, 2, 3], dtype=np.int32)
y = np.array([4, 5, 6], dtype=np.float64)
df = ROOT.RDF.MakeNumpyDataFrame({'x': x, 'y': y})
df = df.Define('z', 'x + y')
df.Display().Print()
df.Snapshot('tree', 'df032_MakeNumpyDataFrame.root')
+-----+---+-----------+-----------+
| Row | x | y | z |
+-----+---+-----------+-----------+
| 0 | 1 | 4.0000000 | 5.0000000 |
+-----+---+-----------+-----------+
| 1 | 2 | 5.0000000 | 7.0000000 |
+-----+---+-----------+-----------+
| 2 | 3 | 6.0000000 | 9.0000000 |
+-----+---+-----------+-----------+
- Date
- March 2021
- Author
- Stefan Wunsch (KIT, CERN)
Definition in file df032_MakeNumpyDataFrame.py.