16 df = ROOT.RDataFrame(10) \
17 .Define(
"x",
"(int)rdfentry_") \
18 .Define(
"y",
"1.f/(1.f+rdfentry_)")
25 print(
"Read-out of the full RDataFrame:\n{}\n".format(npy))
32 df2 = df.Filter(
"x>5")
34 print(
"Read-out of the filtered RDataFrame:\n{}\n".format(npy2))
36 npy3 = df2.AsNumpy(columns=[
"x"])
37 print(
"Read-out of the filtered RDataFrame with the columns option:\n{}\n".format(npy3))
39 npy4 = df2.AsNumpy(exclude=[
"x"])
40 print(
"Read-out of the filtered RDataFrame with the exclude option:\n{}\n".format(npy4))
45 ROOT.gInterpreter.Declare(
"""
46 // Inject the C++ class CustomObject in the C++ runtime.
51 // Create a function that returns such an object. This is called to fill the dataframe.
52 CustomObject fill_object() { return CustomObject(); }
55 df3 = df.Define(
"custom_object",
"fill_object()")
57 print(
"Read-out of C++ objects:\n{}\n".format(npy5[
"custom_object"]))
58 print(
"Access to all methods and data members of the C++ object:\nObject: {}\nAccess data member: custom_object.x = {}\n".format(
59 repr(npy5[
"custom_object"][0]), npy5[
"custom_object"][0].x))
66 print(
"Failed to import pandas.")
69 df = pandas.DataFrame(npy5)
70 print(
"Content of the ROOT.RDataFrame as pandas.DataFrame:\n{}\n".format(df))