I have created a histogram from an RDataFrame object df, and I am trying to convert it to a numpy array by using the following commands (as recommended from another post):
as far as I can tell after you call yvals = hist_mHT.GetArray() RDataFrame and its result are completely out of the picture.
I guess the question is how to build a numpy array from a cppyy.LolLevelView object:
In [1]: import ROOT
In [2]: h = ROOT.RDataFrame(10).Histo1D("rdfentry_")
In [3]: import numpy as np
In [4]: arr = h.GetArray()
In [5]: type(arr)
Out[5]: cppyy.LowLevelView
h1.GetBuffer() returns the unbin content of the histogram (the original data) and the weights you have used to fill the histograms (the default is 1).
I guess you want to convert the bin histogram contents in a numpy array. So in this case you need to use h.GetArray().
So here is the correct code, noting that in case the histogram has automatic binning (i.e. it has a buffer), you might ned to call before calling h.GetArray(), hBufferEmpty()
In addition to what the others have already written, which is correct, I see that in the cppyy docs the conversion from LowLevelView to numpy array is done by using the reshape method of the class (which acts as the SetSize method you tried to use in your original example).
Cheers,
Vincenzo