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