# Definition of RDataframe.Histo1D with a fixed number of bins

**URL:** <https://root-forum.cern.ch/t/definition-of-rdataframe-histo1d-with-a-fixed-number-of-bins/46678>\
**Category:** Newbie\
**Tags:** rdataframe, python\
**Created:** [September 4, 2021, 10:27pm UTC](https://root-forum.cern.ch/t/definition-of-rdataframe-histo1d-with-a-fixed-number-of-bins/46678 "2021-09-04T22:27:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michele99](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/michele99/32/27318_2.png) [@Michele99](https://root-forum.cern.ch/u/Michele99)\
**Post date:** [September 4, 2021, 10:27pm UTC](https://root-forum.cern.ch/t/definition-of-rdataframe-histo1d-with-a-fixed-number-of-bins/46678/1 "2021-09-04T22:27:19Z")

</div>

Hi to everybody, I’d like to define an histogram Histo1D starting from a Rdataframe, but i also would like to specify the number of bins during the creation of this histogram. I tried to use the definition of Histo1D without the number of bins and then the function .SetBins(number of bins, xmin, xmax) but the created histogram has some problems: bin of different size, shape of the histogram that changes depending on the choose of bins or xmin and xmax. I think the problem could be that the histogram is created with a certain number of bins and then is rebinned.  
Is there a correct way to specify the number of bins in the definition of Histo1D?  
Thanks to all,  
Michele

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [September 5, 2021, 4:43am UTC](https://root-forum.cern.ch/t/definition-of-rdataframe-histo1d-with-a-fixed-number-of-bins/46678/2 "2021-09-05T04:43:57Z")

</div>

See the “model” part of the example in the documentation:  
[https://root.cern/doc/master/classROOT\_1\_1RDF\_1\_1RInterface.html#af5b79eb05f2ec0b730ec3b378a2d9ef9](https://root.cern/doc/master/classROOT_1_1RDF_1_1RInterface.html#af5b79eb05f2ec0b730ec3b378a2d9ef9)

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [September 6, 2021, 8:34am UTC](https://root-forum.cern.ch/t/definition-of-rdataframe-histo1d-with-a-fixed-number-of-bins/46678/3 "2021-09-06T08:34:06Z")

</div>

Just adding here that in Python this syntax is allowed:

```python
myDf.Histo1D(("histName", "histTitle", 64u, 0., 128.), "myColumn");

```

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![Michele99](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/michele99/32/27318_2.png) [@Michele99](https://root-forum.cern.ch/u/Michele99)\
**Post date:** [September 6, 2021, 12:45pm UTC](https://root-forum.cern.ch/t/definition-of-rdataframe-histo1d-with-a-fixed-number-of-bins/46678/4 "2021-09-06T12:45:40Z")

</div>

Thank you very much, now it works perfectly!  
Cheers,  
Michele
