22 """A helper class to create the dataset for the tutorial below."""
25 "df036_missingBranches_py_file_1.root",
26 "df036_missingBranches_py_file_2.root",
27 "df036_missingBranches_py_file_3.root",
29 treenames = [
"tree_1",
"tree_2",
"tree_3"]
33 with ROOT.TFile(self.filenames[0],
"RECREATE"):
34 t =
ROOT.TTree(self.treenames[0], self.treenames[0])
40 for i
in range(1, self.nentries + 1):
47 with ROOT.TFile(self.filenames[1],
"RECREATE"):
48 t =
ROOT.TTree(self.treenames[1], self.treenames[1])
52 for i
in range(1, self.nentries + 1):
58 with ROOT.TFile(self.filenames[2],
"RECREATE"):
59 t =
ROOT.TTree(self.treenames[2], self.treenames[2])
63 for i
in range(1, self.nentries + 1):
70 """Enable using the class as a context manager."""
75 Enable using the class as a context manager. At the end of the context,
76 remove the files created.
78 for filename
in self.filenames:
82def df036_missingBranches(dataset: DatasetContext):
98 .DefaultValueFor(
"y", default_value)
99 .Display(columnList=(
"x",
"y"), nRows=15)
104 display_2 =
df.DefaultValueFor(
"y", default_value).FilterAvailable(
"x").Display(columnList=(
"x",
"y"), nRows=15)
109 print(
"Example 1: provide a default value for all missing branches")
111 print(
"Example 2: provide a default value for branch y, but skip events where branch x is missing")
113 print(
"Example 3: only keep events where branch y is missing and display values for branch x")
117if __name__ ==
"__main__":
119 df036_missingBranches(dataset)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...