Use the "trivial data source", an example data source implementation.
This tutorial illustrates how use the RDataFrame in combination with a RDataSource. In this case we use a RTrivialDS, which is nothing more than a simple generator: it does not interface to any existing dataset. The RTrivialDS has a single column, col0, which has value n for entry n.
Note that RTrivialDS is only a demo data source implementation and superior alternatives
typically exist for production use (e.g. constructing an empty RDataFrame as
Author: Danilo Piparo (CERN)
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Monday, March 27, 2023 at 09:45 AM.
Welcome to JupyROOT 6.29/01
Create the data frame
MakeTrivialDataFrame = ROOT.RDF.MakeTrivialDataFrame nEvents = 128 d_s = MakeTrivialDataFrame(nEvents)
Now we have a regular RDataFrame: the ingestion of data is delegated to the RDataSource. At this point everything works as before.
h_s = d_s.Define("x", "1./(1. + col0)").Histo1D(("h_s", "h_s", 128, 0, .6), "x") c = ROOT.TCanvas() c.SetLogy() h_s.Draw() c.SaveAs("df010_trivialDataSource.png") print("Saved figure to df010_trivialDataSource.png")
Saved figure to df010_trivialDataSource.png
Info in <TCanvas::Print>: png file df010_trivialDataSource.png has been created
Draw all canvases
from ROOT import gROOT gROOT.GetListOfCanvases().Draw()