# Bool branch becomes python object with RDataFrame.AsNumpy()

**URL:** <https://root-forum.cern.ch/t/bool-branch-becomes-python-object-with-rdataframe-asnumpy/64305>\
**Category:** ROOT\
**Tags:** rdataframe, python\
**Created:** [October 10, 2025, 11:17am UTC](https://root-forum.cern.ch/t/bool-branch-becomes-python-object-with-rdataframe-asnumpy/64305 "2025-10-10T11:17:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fbetti](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/97f17d/32.png) [@fbetti](https://root-forum.cern.ch/u/fbetti)\
**Post date:** [October 10, 2025, 11:17am UTC](https://root-forum.cern.ch/t/bool-branch-becomes-python-object-with-rdataframe-asnumpy/64305/1 "2025-10-10T11:17:26Z")

</div>

* * *

_ROOT Version:_ 6.36.04  
_Platform:_ macosxarm64  
_Compiler:_ Apple clang version 17.0.0 (clang-1700.0.13.3)

_Python Version:_ 3.13.7

* * *

Hi all,

I see some unexpected behaviour when creating a NumPy arrays dictionary from a RDataFrame. It seems the same reported [here](https://github.com/root-project/root/issues/8639), but I assume it was fixed after. Basically the boolean array from RDataFrame is returned as `object` dtype numpy array. The issue is seen only when the RDataFrame is created from a tree.

Minimal reproducer in python:

```auto
>>> import ROOT
>>> df = ROOT.RDataFrame(10).Define('e', 'rdfentry_').Define('b', 'rdfentry_ == 1')
>>> aa = df.AsNumpy()
>>> aa['b'].dtype
dtype('bool') # as expected
>>> df.Snapshot("temp","temp.root")
<cppyy.gbl.ROOT.RDF.RResultPtr<ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void> > object at 0x600000593a20>

## close and reopen python

>>> import ROOT
>>> df = ROOT.RDataFrame("temp","temp.root")
>>> aa = df.AsNumpy()
>>> aa['b'].dtype
dtype('O') # not expected

```

Thanks in advance for the help

cheers,

Federico

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [October 11, 2025, 10:15am UTC](https://root-forum.cern.ch/t/bool-branch-becomes-python-object-with-rdataframe-asnumpy/64305/2 "2025-10-11T10:15:39Z")

</div>

Hi @fbetti ,

Thanks for reaching out to the forum! I’m not surprised that the example you show does not work because the input type of the column when you snapshot it to disk with TTree will be `Bool_t :`

```auto

>>> df = ROOT.RDataFrame(10).Define('e', 'rdfentry_').Define('b', 'rdfentry_ == 1')
>>> snap = df.Snapshot("temp","temp.root")
>>> snap.GetColumnType("b")
'Bool_t'

```

Whereas the issue that you report was fixed in this PR [[PyROOT][RDF] Support conversion of `bool` columns to NumPy arrays by guitargeek · Pull Request #15180 · root-project/root · GitHub](https://github.com/root-project/root/pull/15180/files) by simply considering the case where the input column is `bool`. So we need to update the logic to also include the `Bool_t` wording, or probably find a better logic, to be seen.

I have created this issue to keep track of progress [Also consider `Bool_t` in numpy array conversion · Issue #20081 · root-project/root · GitHub](https://github.com/root-project/root/issues/20081)

Cheers,

Vincenzo

---

<div class="post-metadata">

**Author:** ![fbetti](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/97f17d/32.png) [@fbetti](https://root-forum.cern.ch/u/fbetti)\
**Post date:** [October 13, 2025, 8:41am UTC](https://root-forum.cern.ch/t/bool-branch-becomes-python-object-with-rdataframe-asnumpy/64305/3 "2025-10-13T08:41:40Z")

</div>

Hi Vincenzo,

thanks a lot for the explanation! I was too naive, I was assuming bool and Bool\_t were equivalent.

I will follow the github issue.

cheers,

Federico

---

<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:** [October 27, 2025, 8:42am UTC](https://root-forum.cern.ch/t/bool-branch-becomes-python-object-with-rdataframe-asnumpy/64305/4 "2025-10-27T08:42:40Z")

</div>

Closed on October 27, 2025, 8:42am UTC

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