Find specific value in dataframes

Hello everybody,

is there any way to search/find if a specific value exists in a RDataFrame?

thank you,
Panagiotis

Hi @panagiotis_bellos ,

one way is:

rdf.Filter("column == value").Range(1).Count()

(where the Range is there to early-quit the event loop as soon as one value satisfying the filter is found).

Cheers,
Enrico

Hi @eguiraud,

thank you for your reply! Basically this takes too long. I tried

d1.Filter([](unsigned long long x) { return x == EN; }, {"event"}).Range(1).Count()

but it looks like the variable EN must be hardcoded. Is it true or I misunderstood?

thanks,
Panagiotis

Basically this takes too long.

Uh, surprising – it shouldn’t take much longer than code this manually, say with a raw for loop over a TTree.

You can capture it!

const auto somevariable = 42;
rdf.Filter([somevariable](unsigned long long x) { return x == somevariable; }, {"event"}).Range(1).Count();

Cheers,
Enrico

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