ROOT
master
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_code
15
##
16
## \date September 2017
17
## \author Danilo Piparo (CERN)
18
19
import
ROOT
20
21
# Create the data frame
22
MakeTrivialDataFrame = ROOT.RDF.MakeTrivialDataFrame
23
24
nEvents = 128
25
26
d_s = MakeTrivialDataFrame(nEvents)
27
28
# Now we have a regular RDataFrame: the ingestion of data is delegated to
29
# the RDataSource. At this point everything works as before.
30
h_s = d_s.Define(
"x"
,
"1./(1. + col0)"
).Histo1D((
"h_s"
,
"h_s"
, 128, 0, .6),
"x"
)
31
32
c = ROOT.TCanvas()
33
c.SetLogy()
34
h_s.Draw()
35
c.SaveAs(
"df010_trivialDataSource.png"
)
36
37
print(
"Saved figure to df010_trivialDataSource.png"
)
tutorials
analysis
dataframe
df010_trivialDataSource.py
ROOT master - Reference Guide Generated on Thu Dec 19 2024 09:47:19 (GVA Time) using Doxygen 1.9.8