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.FromNumpy({'x': x, 'y': y})
df = df.Define('z', 'x + y')
df.Snapshot('tree', 'df032_RDFFromNumpy.root')
void Print(GNN_Data &d, std::string txt="")
+-----+---+----------+----------+
| Row | x | y | z |
+-----+---+----------+----------+
| 0 | 1 | 4.000000 | 5.000000 |
+-----+---+----------+----------+
| 1 | 2 | 5.000000 | 7.000000 |
+-----+---+----------+----------+
| 2 | 3 | 6.000000 | 9.000000 |
+-----+---+----------+----------+
- Date
- March 2021
- Author
- Stefan Wunsch (KIT, CERN)
Definition in file df032_RDFFromNumpy.py.