# Dictionaries needed for RDataFrame(TTree).AsNumpy

**URL:** <https://root-forum.cern.ch/t/dictionaries-needed-for-rdataframe-ttree-asnumpy/63787>\
**Category:** ROOT\
**Tags:** python, root\
**Created:** [June 23, 2025, 2:17pm UTC](https://root-forum.cern.ch/t/dictionaries-needed-for-rdataframe-ttree-asnumpy/63787 "2025-06-23T14:17:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeWhoo](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/e8c25b/32.png) [@LeWhoo](https://root-forum.cern.ch/u/LeWhoo)\
**Post date:** [June 23, 2025, 2:17pm UTC](https://root-forum.cern.ch/t/dictionaries-needed-for-rdataframe-ttree-asnumpy/63787/1 "2025-06-23T14:17:04Z")

</div>

Hi,

I have trees with 1D, 2D and 3D vectors of bools, shorts, etc. I have no problem assigning branches and reading them out in PyROOT directly through TTree. However, when I want to utilise the RDataFrame AsNumpy() function, I get errors like:

“RuntimeError: The column named “trace\_ch” is of type “ROOT::VecOps::RVec\<vector\<vector \>\>”, which is not known to the ROOT interpreter. Please load the corresponding header files or dictionaries.”

I can declare and load the dictionaries in PyROOT, but I wonder if this is really necessary, since reading these values directly from the TTree works without any problem?

* * *

_ROOT Version:_ heads/master@v6-37-01-6541-g9a9e7697e4  
_Platform:_ Fedora 41

* * *

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [June 24, 2025, 3:14pm UTC](https://root-forum.cern.ch/t/dictionaries-needed-for-rdataframe-ttree-asnumpy/63787/2 "2025-06-24T15:14:57Z")

</div>

Hi,

Yes. At the moment the type safety mechanism of RDF require that.

Cheers,  
Danilo

---

<div class="post-metadata">

**Author:** ![LeWhoo](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/e8c25b/32.png) [@LeWhoo](https://root-forum.cern.ch/u/LeWhoo)\
**Post date:** [June 24, 2025, 5:20pm UTC](https://root-forum.cern.ch/t/dictionaries-needed-for-rdataframe-ttree-asnumpy/63787/3 "2025-06-24T17:20:22Z")

</div>

I understand. Still, I have problems with the dictionaries being accepted. For example, I can generate a dictionary for `vector<bool>`:

`ROOT.gInterpreter.GenerateDictionary("vector<vector<bool> >", "vector")`

And I will get a complaint:

`RuntimeError: The column named "adc_enabled_channels_ch" is of type "ROOT::VecOps::RVec<vector<bool>>", which is not known to the ROOT interpreter. Please load the corresponding header files or dictionaries.`

when I call RDataFrame::AsNumpy().

I also tried to load the dictionaries that my C++ counterpart code generates. The load, but the error is the same.

---

<div class="post-metadata">

**Author:** ![LeWhoo](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/e8c25b/32.png) [@LeWhoo](https://root-forum.cern.ch/u/LeWhoo)\
**Post date:** [June 27, 2025, 2:56pm UTC](https://root-forum.cern.ch/t/dictionaries-needed-for-rdataframe-ttree-asnumpy/63787/4 "2025-06-27T14:56:58Z")

</div>

I show here a small working example of the problem with RDataFrame not accepting dictionaries:

```python
import ROOT
import numpy as np

t = ROOT.TTree("t", "t")
v = ROOT.vector["vector<bool>"](np.array([[True, False]]))

t.Branch("v", v)

t.Fill()

t.Scan()

ROOT.gInterpreter.GenerateDictionary("vector<vector<bool> >", "vector")

r = ROOT.RDataFrame(t)

r.AsNumpy()

```

output:

```auto
Traceback (most recent call last):
  File "/tmp/./vector_sample.py", line 19, in <module>
    r.AsNumpy()
    ~~~~~~~~~ ^^
  File "/home/lewhoo/software/root/root/lib/ROOT/_pythonization/_rdataframe.py", line 274, in RDataFrameAsNumpy
    raise RuntimeError(
        f'The column named "{column}" is of type "{column_type}", which is not known to the ROOT interpreter. Please load the corresponding header files or dictionaries.'
    )
RuntimeError: The column named "v" is of type "ROOT::VecOps::RVec<vector<bool>>", which is not known to the ROOT interpreter. Please load the corresponding header files or dictionaries.

```

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [July 11, 2025, 2:57pm UTC](https://root-forum.cern.ch/t/dictionaries-needed-for-rdataframe-ttree-asnumpy/63787/5 "2025-07-11T14:57:57Z")

</div>

Closed on July 11, 2025, 2:57pm UTC

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