From 87c69d542ff8db9c4d9063dfac50acfb7491923f Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Sun, 17 Jul 2022 22:22:55 +0200 Subject: [PATCH] REF: avoid converting input to cut if passing IntervalIndex bins --- pandas/core/reshape/tile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/reshape/tile.py b/pandas/core/reshape/tile.py index 00b2b30eb3122..05005006ad9e4 100644 --- a/pandas/core/reshape/tile.py +++ b/pandas/core/reshape/tile.py @@ -240,7 +240,9 @@ def cut( original = x x = _preprocess_for_cut(x) - x, dtype = _coerce_to_type(x) + dtype = None + if not isinstance(bins, IntervalIndex): + x, dtype = _coerce_to_type(x) if not np.iterable(bins): if is_scalar(bins) and bins < 1: