Does anyone know how to convert a one-element RVect<float> into a float?

I have to deal with a variable which in general is RVec but in this specific case has only one element. The thing is that I cannot make comparisons between “RVec” and “float” variables so I wanted to change the data type from “RVec” to “float”.


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

Hi @imanol097 ,

the simplest way is just vec[0]. The best solution might depend on the actual use case.


Hi @eguiraud , I already tried that, but when converting my DataFrame into numpy array seems that this variable type is still a RVec:

[<cppyy.gbl.ROOT.VecOps.RVec object at 0x7f50c0f57090>]

This should work:

df.Define("x", "vec[0]").AsNumpy(["x"])

It works, thanks @eguiraud .