No TTree.AsMatrix() and RDataFrame in experimental PyROOT?

I have a simple tree -

>>> import ROOT
>>> f = ROOT.TFile.Open("testbasket.root")
>>> tree = f.Get("t")
>>> tree.Print()
*Tree    :t         :                                                        *
*Entries :        5 : Total =             921 bytes  File  Size =        925 *
*        :          : Tree compression factor =   1.00                       *
*Br    0 :intBranch : intBranch/I                                            *
*Entries :        5 : Total  Size=        598 bytes  File Size  =         93 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *

With ROOT compiled without experimental PyROOT -

>>> tree.AsMatrix()
>>> rdf = ROOT.RDataFrame(tree)
>>> rdf.AsNumpy()
{'intBranch': numpy.array([1, 2, 3, 4, 5], dtype=int32)}

With ROOT compiled with experimental PyROOT -

>>> tree.AsMatrix()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'TTree' object has no attribute 'AsMatrix'
>>> rdf = ROOT.RDataFrame(tree)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/reik/test/root/build-dir2/lib/ROOT/", line 54, in <lambda>
    self.__class__.__getattr__ = lambda self, name: getattr(gbl_namespace, name)
AttributeError: <namespace cppyy.gbl at 0x55a69116ba50> has no attribute 'RDataFrame'. Full details:
  type object '' has no attribute 'RDataFrame'
  'RDataFrame' is not a known C++ class
  'RDataFrame' is not a known C++ template
  'RDataFrame' is not a known C++ enum

Can cppyy not handle AsMatrix() and RDataFrame yet?


What is the ROOT version you are running? That’s the key to the answer. Currently on master (and in the next release) everything you show above works.

If you run on 6.18, the experimental PyROOT should work with RDataFrame.AsNumpy but we haven’t yet ported TTree.AsMatrix. As well, note that you have to write ROOT.ROOT.RDataFrame in experimental PyROOT in 6.18. But as well this is fixed on master :wink:

We are aware that in the current release of ROOT, the TTree.AsMatrix is not yet ported to experimental PyROOT. We have fixed this already in master for backward compatibility.

Feel free to reach out again if I confused you too much!



This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.