ROOT
v6-32
Reference Guide
Loading...
Searching...
No Matches
df031_Stats.C
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
15
void
df031_Stats
() {
16
17
// Create a data frame and add two columns: one for the values and one for the weight.
18
ROOT::RDataFrame
r
(256);
19
auto
rr
=
r
.Define(
"v"
, [](
ULong64_t
e
){
return
e
;}, {
"rdfentry_"
})
20
.Define(
"w"
, [](
ULong64_t
e
){
return
1./(
e
+1);}, {
"v"
});
21
22
// Now extract the statistics, weighted, unweighted - with and without explicit types.
23
auto
stats_eu
=
rr
.Stats<
ULong64_t
>(
"v"
);
24
auto
stats_ew
=
rr
.Stats<
ULong64_t
,
double
>(
"v"
,
"w"
);
25
auto
stats_iu
=
rr
.Stats(
"v"
);
26
auto
stats_iw
=
rr
.Stats(
"v"
,
"w"
);
27
28
// Now print them: they are all identical of course!
29
stats_eu
->Print();
30
stats_ew
->Print();
31
stats_iu
->Print();
32
stats_iw
->Print();
33
}
e
#define e(i)
Definition
RSha256.hxx:103
ULong64_t
unsigned long long ULong64_t
Definition
RtypesCore.h:81
r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Definition
TGWin32VirtualXProxy.cxx:168
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
ROOT::RDataFrame
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
Definition
RDataFrame.hxx:41
df031_Stats
Definition
df031_Stats.py:1
tutorials
dataframe
df031_Stats.C
ROOT v6-32 - Reference Guide Generated on Fri Jan 24 2025 14:10:44 (GVA Time) using Doxygen 1.10.0