Skip to content

Commit

Permalink
add test in test_qcut.py and bug fix report in doc/source/whatsnew
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisMountn committed Dec 11, 2023
1 parent 990572f commit 4ef1a5a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v2.1.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Bug fixes
- Fixed bug in :meth:`Series.reset_index` not preserving object dtype when ``infer_string`` is set (:issue:`56160`)
- Fixed bug in :meth:`Series.str.split` and :meth:`Series.str.rsplit` when ``pat=None`` for :class:`ArrowDtype` with ``pyarrow.string`` (:issue:`56271`)
- Fixed bug in :meth:`Series.str.translate` losing object dtype when string option is set (:issue:`56152`)
- Fixed bug in :func:`qcut` resulting in bad cuts for too many occurrences of a minimum value of a sequence (:issue:`55991`)


.. ---------------------------------------------------------------------------
.. _whatsnew_214.contributors:
Expand Down
13 changes: 13 additions & 0 deletions pandas/tests/reshape/test_qcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ def test_qcut_return_intervals():
)
tm.assert_series_equal(res, exp)

def test_qcut_multiple_min_values():
data = [0] * 3 + [1] * 2 + [2, 3, 4, 5] # 10 sample

temp = qcut(x=data, q=5, duplicates='drop').value_counts().sort_index()

intervals = IntervalIndex.from_tuples([(-0.001, 0.0), (0.0, 1.0), (1.0, 3.0), (3.0, 5.0)])
counts = [3, 2, 2, 2]
series = Series(counts, index=intervals)

temp.index = intervals
temp.name = None
tm.assert_series_equal(temp, series)


@pytest.mark.parametrize("labels", ["foo", 1, True])
def test_qcut_incorrect_labels(labels):
Expand Down

0 comments on commit 4ef1a5a

Please sign in to comment.