Logo ROOT  
Reference Guide
df010_trivialDataSource.py
Go to the documentation of this file.
1## \file
2## \ingroup tutorial_dataframe
3## \notebook -draw
4## This tutorial illustrates how use the RDataFrame in combination with a
5## RDataSource. In this case we use a TTrivialDS, which is nothing more
6## than a simple generator: it does not interface to any existing dataset.
7## The TTrivialDS has a single column, col0, which has value n for entry n.
8##
9## \macro_code
10##
11## \date September 2017
12## \author Danilo Piparo
13
14import ROOT
15
16# Create the data frame
17MakeTrivialDataFrame = ROOT.RDF.MakeTrivialDataFrame
18
19nEvents = 128
20
21d_s = MakeTrivialDataFrame(nEvents)
22
23# Now we have a regular RDataFrame: the ingestion of data is delegated to
24# the RDataSource. At this point everything works as before.
25h_s = d_s.Define("x", "1./(1. + col0)").Histo1D(("h_s", "h_s", 128, 0, .6), "x")
26
27c = ROOT.TCanvas()
28c.SetLogy()
29h_s.Draw()
30
RInterface< RDFDetail::RLoopManager, RTrivialDS > MakeTrivialDataFrame(ULong64_t size, bool skipEvenEntries=false)
Definition: RTrivialDS.cxx:92