Skip to content

Commit 7bb010c

Browse files
mroeschkejreback
authored andcommitted
CLN: Delay converting bins to datelike until necessary (#21724)
1 parent 2b13605 commit 7bb010c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pandas/core/reshape/tile.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def cut(x, bins, right=True, labels=None, retbins=False, precision=3,
235235
duplicates=duplicates)
236236

237237
return _postprocess_for_cut(fac, bins, retbins, x_is_series,
238-
series_index, name)
238+
series_index, name, dtype)
239239

240240

241241
def qcut(x, q, labels=None, retbins=False, precision=3, duplicates='raise'):
@@ -307,7 +307,7 @@ def qcut(x, q, labels=None, retbins=False, precision=3, duplicates='raise'):
307307
dtype=dtype, duplicates=duplicates)
308308

309309
return _postprocess_for_cut(fac, bins, retbins, x_is_series,
310-
series_index, name)
310+
series_index, name, dtype)
311311

312312

313313
def _bins_to_cuts(x, bins, right=True, labels=None,
@@ -365,8 +365,6 @@ def _bins_to_cuts(x, bins, right=True, labels=None,
365365
result = result.astype(np.float64)
366366
np.putmask(result, na_mask, np.nan)
367367

368-
bins = _convert_bin_to_datelike_type(bins, dtype)
369-
370368
return result, bins
371369

372370

@@ -511,7 +509,7 @@ def _preprocess_for_cut(x):
511509

512510

513511
def _postprocess_for_cut(fac, bins, retbins, x_is_series,
514-
series_index, name):
512+
series_index, name, dtype):
515513
"""
516514
handles post processing for the cut method where
517515
we combine the index information if the originally passed
@@ -523,6 +521,8 @@ def _postprocess_for_cut(fac, bins, retbins, x_is_series,
523521
if not retbins:
524522
return fac
525523

524+
bins = _convert_bin_to_datelike_type(bins, dtype)
525+
526526
return fac, bins
527527

528528

0 commit comments

Comments
 (0)