Read data from Pandas Data Frame into RDataFrame.
import ROOT
import pandas as pd
pdf = pd.DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]})
df = ROOT.RDF.FromPandas(pdf)
df = df.Define('z', 'x + y')
df.Snapshot('tree', 'df035_RDFFromPandas.root')
void Print(GNN_Data &d, std::string txt="")
+-----+---+---+---+
| Row | x | y | z |
+-----+---+---+---+
| 0 | 1 | 4 | 5 |
+-----+---+---+---+
| 1 | 2 | 5 | 7 |
+-----+---+---+---+
| 2 | 3 | 6 | 9 |
+-----+---+---+---+
- Date
- February 2024
- Author
- Pere Mato (CERN)
Definition in file df035_RDFFromPandas.py.