Df 0 3 1_ Stats

Extract the statistics relative to RDataFrame columns and store them in TStatistic instances.

Author: Danilo Piparo
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Monday, July 06, 2020 at 11:41 AM.

In [1]:
import ROOT
Welcome to JupyROOT 6.23/01

Create a data frame and add two columns: one for the values and one for the weight.

In [2]:
r = ROOT.RDataFrame(256);
rr = r.Define("v", "rdfentry_")\
      .Define("w", "return 1./(v+1)")

Now extract the statistics, weighted, unweighted

In [3]:
stats_iu = rr.Stats("v")
stats_iw = rr.Stats("v", "w")

Now print them: they are all identical of course!

In [4]:
stats_iu.Print()
stats_iw.Print()
 OBJ: TStatistic	  	 Mean = 127.5 +- 4.628 	 RMS = 74.045 	 Count = 256 	 Min = 0 	 Max = 255
 OBJ: TStatistic	  	 Mean = 40.8 +- 12.86 	 RMS = 60.318 	 Count = 256 	 Min = 0 	 Max = 255

Draw all canvases

In [5]:
from ROOT import gROOT 
gROOT.GetListOfCanvases().Draw()