Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
df031_Stats.py
Go to the documentation of this file.
1 ## \file
2 ## \ingroup tutorial_dataframe
3 ## \notebook
4 ##
5 ## Extract the statistics relative to RDataFrame columns and store them
6 ## in TStatistic instances.
7 ##
8 ## \macro_code
9 ## \macro_output
10 ##
11 ## \date April 2019
12 ## \author Danilo Piparo
13 
14 import ROOT
15 
16 # Create a data frame and add two columns: one for the values and one for the weight.
17 r = ROOT.ROOT.RDataFrame(256);
18 rr = r.Define("v", "rdfentry_")\
19  .Define("w", "return 1./(v+1)")
20 
21 # Now extract the statistics, weighted, unweighted
22 stats_iu = rr.Stats("v")
23 stats_iw = rr.Stats("v", "w")
24 
25 # Now print them: they are all identical of course!
26 stats_iu.Print()
27 stats_iw.Print()