Df 0 3 1_ Stats

Use the Stats action to extract the statistics of a column.

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

Author: Danilo Piparo (CERN)
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Thursday, June 24, 2021 at 07:19 AM.

In [ ]:
import ROOT

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

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

Now extract the statistics, weighted, unweighted

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

Now print them: they are all identical of course!

In [ ]:
stats_iu.Print()
stats_iw.Print()

Draw all canvases

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