8sum = df.Filter(
"x > 10").Sum(
"y")
12### User code in the RDataFrame workflow
25# JIT a C++ function from Python
26ROOT.gInterpreter.Declare(
"""
27bool myFilter(float x) {
33# Use the function in an RDF operation
34sum = df.Filter(
"myFilter(x)").Sum(
"y")
45sum = df.Filter(
"myFilter(x)").Sum(
"y")
60@
ROOT.Numba.Declare([
"float"],
"bool")
64df =
ROOT.RDataFrame(
"myTree",
"myFile.root")
72@
ROOT.Numba.Declare([
'RVec<float>',
'int'],
'RVec<float>')
76df.Define(
'array',
'ROOT::RVecF{1.,2.,3.}')\
77 .Define(
'arraySquared',
'Numba::pypowarray(array, 2)')
95print(
rdf.AsNumpy([
"int_col",
"float_col"]))
96# Output: {'int_col': array([...], dtype=int32), 'float_col': array([...], dtype=float64)}
108rdf =
rdf.Define(
"v_col",
"std::vector<int>{{1, 2, 3}}")
109print(
rdf.AsNumpy([
"v_col",
"int_col",
"float_col"]))
110# Output: {'v_col': array([array([1, 2, 3], dtype=int32), ...], dtype=object), ...}
128# Read data from NumPy arrays
129# The column names in the RDataFrame are taken from the dictionary keys
130x,
y = numpy.array([1, 2, 3]), numpy.array([4, 5, 6])
133# Use RDataFrame as
usual,
e.g. write out
a ROOT file
134df.Define(
"z",
"x + y").Snapshot(
"tree",
"file.root")
139### Interoperability with [AwkwardArray](https:
147array = ak.from_rdataframe(
166 {
"x": [1.1, 1.2, 1.3]},
169 {
"x": [4.1, 4.2, 4.3, 4.4]},
174array_z =
ak.Array([[1.1], [2.1, 2.3, 2.4], [3.1], [4.1, 4.2, 4.3], [5.1]])
191# First argument is a tuple with the arguments to construct a TH1D model
192h = df.Histo1D((
"histName",
"histTitle", 64, 0., 128.),
"myColumn")
195### AsRNode helper function
200ROOT.gInterpreter.Declare(
"""
201ROOT::RDF::RNode MyTransformation(ROOT::RDF::RNode df) {
202 auto myFunc = [](float x){ return -x;};
203 return df.Define("y", myFunc, {"x"});
207# Cast the RDataFrame head node
211# ... or any other node
212df2 = df.Filter(
"x > 42")
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void when
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
The public interface to the RDataFrame federation of classes.
RInterface< Proxied, DS_t > Define(std::string_view name, F expression, const ColumnNames_t &columns={})
Define a new column.
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
RooCmdArg Columns(Int_t ncol)
T Sum(const RVec< T > &v, const T zero=T(0))
Sum elements of an RVec.
RVec< T > Filter(const RVec< T > &v, F &&f)
Create a new collection with the elements passing the filter expressed by the predicate.
ROOT::VecOps::RVec< T > RVec
RNode AsRNode(NodeType node)
Cast a RDataFrame node to the common type ROOT::RDF::RNode.
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
constexpr Double_t C()
Velocity of light in .
static uint64_t sum(uint64_t i)