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