Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

Commit

Permalink
pass the title through as an index name
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski committed Sep 26, 2018
1 parent bdc2f78 commit da109f7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions uproot_methods/classes/TH1.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,15 @@ def pandas(self, underflow=True, overflow=True, variance=True):
elif not overflow:
edges = edges[:-1]

if getattr(self, "_fTitle", b"") == b"":
name = None
else:
name = self._fTitle.decode("utf-8", "ignore")

lefts, rights = edges[:-1], edges[1:]

nonzero = (freq != 0.0)
index = pandas.IntervalIndex.from_arrays(lefts[nonzero], rights[nonzero], closed="left")
index = pandas.IntervalIndex.from_arrays(lefts[nonzero], rights[nonzero], closed="left", name=name)

data = {"count": freq[nonzero]}
columns = ["count"]
Expand Down Expand Up @@ -423,7 +428,12 @@ def __init__(self, fNbins, fXmin, fXmax):
out._fTsumwx = (content * centers).sum()
out._fTsumwx2 = (content * centers**2).sum()

out._fTitle = b""
if histogram.index.name is None:
out._fTitle = b""
elif isinstance(histogram.index.name, bytes):
out._fTitle = histogram.index.name
else:
out._fTitle = histogram.index.name.encode("utf-8", "ignore")

out._classname, content = _histtype(content)

Expand Down

0 comments on commit da109f7

Please sign in to comment.