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 Sunday, January 19, 2020 at 01:04 AM.

In [1]:
// Create a data frame and add two columns: one for the values and one for the weight.
 ROOT::RDataFrame r(256);
 auto rr = r.Define("v", [](ULong64_t e){return e;}, {"rdfentry_"})
            .Define("w", [](ULong64_t e){return 1./(e+1);}, {"v"});
 
 // Now extract the statistics, weighted, unweighted - with and without explicit types.
 auto stats_eu = rr.Stats<ULong64_t>("v");
 auto stats_ew = rr.Stats<ULong64_t, double>("v", "w");
 auto stats_iu = rr.Stats("v");
 auto stats_iw = rr.Stats("v", "w");

 // Now print them: they are all identical of course!
 stats_eu->Print();
 stats_ew->Print();
 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
 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 [2]:
gROOT->GetListOfCanvases()->Draw()