Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 RTrivialDS, which is nothing more
8## than a simple generator: it does not interface to any existing dataset.
9## The RTrivialDS has a single column, col0, which has value n for entry n.
10##
11## Note that RTrivialDS is only a demo data source implementation and superior alternatives
12## typically exist for production use (e.g. constructing an empty RDataFrame as `RDataFrame(nEntries)`).
13##
14## \macro_image
15## \macro_code
16##
17## \date September 2017
18## \author Danilo Piparo (CERN)
19
20import ROOT
21
22# Create the data frame
23MakeTrivialDataFrame = ROOT.RDF.MakeTrivialDataFrame
24
25nEvents = 128
26
27d_s = MakeTrivialDataFrame(nEvents)
28
29# Now we have a regular RDataFrame: the ingestion of data is delegated to
30# the RDataSource. At this point everything works as before.
31h_s = d_s.Define("x", "1./(1. + col0)").Histo1D(("h_s", "h_s", 128, 0, .6), "x")
32
33c = ROOT.TCanvas()
36c.SaveAs("df010_trivialDataSource.png")
37
38print("Saved figure to df010_trivialDataSource.png")
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.