Skip to content

Commit dca5475

Browse files
Ajay SaxenaAjay Saxena
Ajay Saxena
authored and
Ajay Saxena
committed
added changes to qcut code
1 parent 8cca6af commit dca5475

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pandas/tools/tile.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,23 @@ def qcut(x, q, labels=None, retbins=False, precision=3):
179179
>>> pd.qcut(range(5), 4, labels=False)
180180
array([0, 0, 1, 2, 3], dtype=int64)
181181
"""
182+
dtype = None
183+
if is_timedelta64_dtype(x):
184+
x = x.astype(np.int64)
185+
dtype = np.timedelta64
186+
187+
if is_datetime64_dtype(x):
188+
x = x.astype(np.int64)
189+
dtype = np.datetime64
190+
182191
if is_integer(q):
183192
quantiles = np.linspace(0, 1, q + 1)
184193
else:
185194
quantiles = q
186195
bins = algos.quantile(x, quantiles)
187196
return _bins_to_cuts(x, bins, labels=labels, retbins=retbins,
188-
precision=precision, include_lowest=True)
197+
precision=precision, include_lowest=True,
198+
dtype=dtype)
189199

190200

191201
def _bins_to_cuts(x, bins, right=True, labels=None, retbins=False,

0 commit comments

Comments
 (0)