Histogram RVec branch in RDataFrame

In my TTree, I have an RVec branch for the energy in each detector channel. When using RDataFrame, why do I have to define a new column to create a histogram of a single channel? For example, why do you have to use this:

df = ROOT.RDataFrame('<treename>', 'root://<path/to/file>.root')
h = df.Define('px_0', 'px[0]').Histo1D('px_0')

instead of just using this:

df = ROOT.RDataFrame('<treename>', 'root://<path/to/file>.root')
h = df.Histo1D('px[0]')

ROOT Version: 6.24/06
Platform: Mac 12.3
Compiler: Not Provided

Hi @certley ,
and welcome to the ROOT forum!

Allowing expressions in place of column names could be done; on one hand it would save typing for users, on the other it would encourage some not-so-nice usage patterns and complicate internals. See also my reply here: Create Histogram of composite variable in RDataframe - #2 by eguiraud .

I have been thinking about it and a possible middle ground would be:


but I don’t know if it’s worth it :sweat_smile:

Thank you, that clears it up for me. Your link was also very helpful.