# How to get bin content of all bins along x and y axis of a 2D histograms in python uproot

**URL:** <https://root-forum.cern.ch/t/how-to-get-bin-content-of-all-bins-along-x-and-y-axis-of-a-2d-histograms-in-python-uproot/57926>\
**Category:** Newbie\
**Tags:** python\
**Created:** [January 22, 2024, 2:54pm UTC](https://root-forum.cern.ch/t/how-to-get-bin-content-of-all-bins-along-x-and-y-axis-of-a-2d-histograms-in-python-uproot/57926 "2024-01-22T14:54:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elemental](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/elemental/32/34841_2.png) [@elemental](https://root-forum.cern.ch/u/elemental)\
**Post date:** [January 22, 2024, 2:54pm UTC](https://root-forum.cern.ch/t/how-to-get-bin-content-of-all-bins-along-x-and-y-axis-of-a-2d-histograms-in-python-uproot/57926/1 "2024-01-22T14:54:41Z")

</div>

I would like to write a uproot script in python to get the bin content in all bins(boxes) in a 2D histogram and add it to a vector and then print it to a .txt file with bin size on x and y axis as first line and then bin content value line-by-line i.e. rows and then columns.

Is this possible to do with uproot package on python function that takes the root file and the histogram name as input.

Essentially, I would like to know how to get bin content of all bins along x and y axis of a 2D histograms. What functions to use in uproot ?

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [January 22, 2024, 7:30pm UTC](https://root-forum.cern.ch/t/how-to-get-bin-content-of-all-bins-along-x-and-y-axis-of-a-2d-histograms-in-python-uproot/57926/2 "2024-01-22T19:30:49Z")

</div>

Hi @elemental!

[uproot](https://github.com/scikit-hep/uproot5) is not part of ROOT, but a separate package that re-implements ROOT IO. Therefore you need to ask for help somewhere else, since this is the support forum for [CERN’s ROOT](https://root.cern.ch/).
