Skip to content

Commit 86c1047

Browse files
Return histogram bins as list of floats instead of a pd.Interval object (#1207)
* return histogram bins as list of floats * update release notes * fix release notes * Update docs/source/release_notes.rst Co-authored-by: Roy Wedge <[email protected]> Co-authored-by: Roy Wedge <[email protected]>
1 parent c1ec07d commit 86c1047

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

docs/source/release_notes.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@
22

33
Release Notes
44
-------------
5-
.. Future Release
6-
==============
5+
Future Release
6+
==============
77
* Enhancements
88
* Fixes
99
* Changes
10+
* Return histogram bins as a list of floats instead of a ``pandas.Interval`` object (:pr:`1207`)
1011
* Documentation Changes
1112
* Testing Changes
1213

13-
.. Thanks to the following people for contributing to this release:
14+
Thanks to the following people for contributing to this release:
15+
:user:`thehomebrewnerd`
16+
17+
Breaking Changes
18+
++++++++++++++++
19+
* :pr:``1207``: The behavior of ``describe_dict`` has changed when using
20+
``extra_stats=True``. Previously, the histogram bins were returned as
21+
``pandas.Interval`` objects. This has been updated so that the histogram
22+
bins are now represented as a two-element list of floats with the first element
23+
being the left edge of the bin and the second element being the right edge.
1424

1525
v0.9.1 Nov 19, 2021
1626
===================

woodwork/statistics_utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,13 @@ def _get_histogram_values(series, bins=10):
630630
values = pd.cut(series, bins=bins, duplicates="drop").value_counts().sort_index()
631631
df = values.reset_index()
632632
df.columns = ["bins", "frequency"]
633-
return list(df.to_dict(orient="index").values())
633+
results = []
634+
for _, row in df.iterrows():
635+
results.append(
636+
{
637+
"bins": [row["bins"].left, row["bins"].right],
638+
"frequency": row["frequency"],
639+
}
640+
)
641+
642+
return results

woodwork/tests/accessor/test_statistics.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,9 @@ def test_numeric_histogram():
959959
total = 0
960960
for info in values:
961961
assert "bins" in info
962+
assert len(info["bins"]) == 2
963+
assert isinstance(info["bins"][0], float)
964+
assert isinstance(info["bins"][1], float)
962965
assert "frequency" in info
963966
freq = info["frequency"]
964967
total += freq

0 commit comments

Comments
 (0)