# Problems filtering a vector with a scalar

**URL:** <https://root-forum.cern.ch/t/problems-filtering-a-vector-with-a-scalar/64922>\
**Category:** Newbie\
**Tags:** python, rdataframe, root\
**Created:** [June 29, 2026, 1:50pm UTC](https://root-forum.cern.ch/t/problems-filtering-a-vector-with-a-scalar/64922 "2026-06-29T13:50:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abirze](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/abirze/32/39953_2.png) [@abirze](https://root-forum.cern.ch/u/abirze)\
**Post date:** [June 29, 2026, 1:50pm UTC](https://root-forum.cern.ch/t/problems-filtering-a-vector-with-a-scalar/64922/1 "2026-06-29T13:50:56Z")

</div>

I’m trying to filter values of a RDFrame, but the elements in the RDFrame are vectors and it seems like i’m trying to do vector to scalar comparison.

Been trying to do  
`df_data.Filter(f'ALL_hits_S == {float(section)}')`  
where I want to make a histogram of `ALL_hists_X[ALL_hits_S == 0]` for example  
-----±-----------+  
| Row | ALL\_hits\_S |  
±----±-----------+  
| 0 | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | … |  
±----±-----------+  
| 1 | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | … |  
±----±-----------+  
| 2 | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
| | 0.000000 |  
.  
.  
.

* * *

_Platform: Lxplus_

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [June 30, 2026, 8:06am UTC](https://root-forum.cern.ch/t/problems-filtering-a-vector-with-a-scalar/64922/2 "2026-06-30T08:06:40Z")

</div>

Welcome to the ROOT forum.  
I guess @vpadulan might help you.

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [June 30, 2026, 9:14am UTC](https://root-forum.cern.ch/t/problems-filtering-a-vector-with-a-scalar/64922/3 "2026-06-30T09:14:10Z")

</div>

Check out the example in the Documentation ([ROOT: ROOT::RDataFrame Class Reference](https://root.cern/doc/master/classROOT_1_1RDataFrame.html#working_with_collections)), which uses Define to do the selection.

---

<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:** [July 8, 2026, 4:14pm UTC](https://root-forum.cern.ch/t/problems-filtering-a-vector-with-a-scalar/64922/4 "2026-07-08T16:14:32Z")

</div>

> [@abirze](#):
>
> `ALL_hists_X[ALL_hits_S == 0]`

Dear @abirze ,

Thank you for reaching out to the forum! I agree with @dastudillo , this is a typical example of working with collections in RDataFrame. The idea is that `Filter` is only useful if you want to either discard or keep the entire event. Instead, if you want to select some values from your collection but still keep the event, you should use `Define` to create a temporary collection with the correct values and then you can call `Histo1D` on that new column.

Let us know if it works for you, thanks!  
Cheers,  
Vincenzo
