14def fill_tree(treeName, fileName):
15 tdf = ROOT.ROOT.RDataFrame(100)
16 tdf.Define(
"b1",
"(int) tdfentry_")\
17 .Define(
"b2",
"(float) tdfentry_ * tdfentry_").Snapshot(treeName, fileName)
21fileName =
"df006_ranges_py.root"
24fill_tree(treeName, fileName)
27RDF = ROOT.ROOT.RDataFrame
28d = RDF(treeName, fileName)
35d_0_30 = d.Range(0, 30)
36c_0_30 = d_0_30.Count()
39d_15_end = d.Range(15, 0)
40c_15_end = d_15_end.Count()
43d_15_end_3 = d.Range(15, 0, 3)
44c_15_end_3 = d_15_end_3.Count()
48d_0_50 = d.Range(0, 50)
49c_0_50_odd_b1 = d_0_50.Filter(
"1 == b1 % 2").Count()
54c_0_3_after_even_b1 = d.Filter(
"0 == b1 % 2").
Range(0, 3).Count()
57print(
"Usage of ranges:")
58print(
" - All entries:", c_all.GetValue())
59print(
" - Entries from 0 to 30:", c_0_30.GetValue())
60print(
" - Entries from 15 onwards:", c_15_end.GetValue())
61print(
" - Entries from 15 onwards in steps of 3:", c_15_end_3.GetValue())
62print(
" - Entries from 0 to 50, odd only:", c_0_50_odd_b1.GetValue())
63print(
" - First three entries of all even entries:", c_0_3_after_even_b1.GetValue())