This works fine, but I can’t manage to pass on my chosen histogram parameters.
Also, is it possible to define the histogram type, both in C++ and python?
Hi Sara,
for what concerns passing your own histogram parameters also from python, it’s coming with the next release (6.12, in November) and it is already possible if you compile our master branch from source. It looks like this:
d = ROOT.ROOT.Experimental.TDataFrame("tree", "file.root")
h = d.Histo1D(("h", "h", 128, 0, 1), "x")
Changing the type of the histogram used by Histo1D is not currently possible, but from C++ you can pass whatever object has a Fill method to the Fill action:
ROOT::Experimental::TDataFrame d(10);
// define column "x" to always return 42 and fill a TH2I with it
auto hi = d.Define("x", "42").Fill(TH2I("hi", "hi", 100, 0, 10), {"x"});
hi->Draw();
Filling a generic object via Fill is not currently possible from python, but we might add it if there’s enough request for it, so let us know if you have a use-case that requires it!
thanks for the quick answer. I will have to be a little patient then, as I unfortunately need to run this in more places than just on my own laptop.
Concerning the Fill functionality in python, I suppose being able to set the parameters in Histo1D is already a nice start, but undoubtedly one is at some point going to want to fill for example a histogram with non-equidistant (e.g. logarithmic) binning. In that case the original d.Histo1D(("h", "h", 128, 0, 1), "x") is no longer sufficient and something like Fill(object,"x") would be required.