Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
df031_Stats.C File Reference

Detailed Description

View in nbviewer Open in SWAN Use the Stats action to extract the statistics of a column.

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

void df031_Stats() {
// Create a data frame and add two columns: one for the values and one for the weight.
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();
}
ROOT::R::TRInterface & r
Definition Object.C:4
#define e(i)
Definition RSha256.hxx:103
unsigned long long ULong64_t
Definition RtypesCore.h:74
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
Definition TObject.cxx:552
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
Date
April 2019
Author
Danilo Piparo (CERN)

Definition in file df031_Stats.C.