Logo ROOT  
Reference Guide
df010_trivialDataSource.py File Reference


namespace  df010_trivialDataSource

Detailed Description

View in nbviewer Open in SWAN 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 TTrivialDS, which is nothing more than a simple generator: it does not interface to any existing dataset. The TTrivialDS has a single column, col0, which has value n for entry n.

import ROOT
# 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()
print("Saved figure to df010_trivialDataSource.png")
RInterface< RDFDetail::RLoopManager, RTrivialDS > MakeTrivialDataFrame(ULong64_t size, bool skipEvenEntries=false)
Definition: RTrivialDS.cxx:116
September 2017
Danilo Piparo (CERN)

Definition in file df010_trivialDataSource.py.