Home | News | Documentation | Download

RDataFrame all possible combination

Dear Rooter,

I have a csv file and I read it using ROOT::RDF::MakeCsvDataFrame. I want to make all possible combinations among all entries of the dataframe (nested 2 for loops). What is the best way to do it?

I know Foreach method do loop over all entries, but it is not clear how make all possible combinations.
unsigned int n{};
df.Foreach([&n](int j) { ++n; std::cout << j << std::endl; }, {"column"});

Thank you very much,

Hi,
RDataFrame does not provide a way to loop over all possible combinations of entry pairs (and if it did, it would be very slow, because RDF reads data from disk and this would required n_entries event loops!).

You could instead read your data into vectors with the Take action and then do a nested for loop over these vectors.

Hope this helps!
Enrico

1 Like

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