Skip to content

Commit b496947

Browse files
Ajay SaxenaAjay Saxena
Ajay Saxena
authored and
Ajay Saxena
committed
code review comments
1 parent 12ab384 commit b496947

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

pandas/tools/tests/test_tile.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,14 @@ def test_single_bin(self):
285285
tm.assert_series_equal(result, expected)
286286

287287
def test_datetime_cut(self):
288+
# GH 14714
288289
data = to_datetime(Series(['2013-01-01', '2013-01-02', '2013-01-03']))
289-
result = cut(data, 3)
290-
self.assertEqual(result[0],
291-
'(2012-12-31 23:57:07.200000, 2013-01-01 16:00:00]')
292-
self.assertEqual(result[1],
293-
'(2013-01-01 16:00:00, 2013-01-02 08:00:00]')
294-
self.assertEqual(result[2],
295-
'(2013-01-02 08:00:00, 2013-01-03 00:00:00]')
290+
result, bins = cut(data, 3, retbins=True)
291+
expected = Series(['(2012-12-31 23:57:07.200000, 2013-01-01 16:00:00]',
292+
'(2013-01-01 16:00:00, 2013-01-02 08:00:00]',
293+
'(2013-01-02 08:00:00, 2013-01-03 00:00:00]'],
294+
).astype("category", ordered=True)
295+
tm.assert_series_equal(result, expected)
296296

297297

298298
def curpath():

pandas/tools/tile.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import pandas.core.algorithms as algos
1212
import pandas.core.nanops as nanops
1313
from pandas.compat import zip
14-
from pandas.tseries.timedeltas import to_timedelta
14+
from pandas import to_timedelta
1515
from pandas import to_datetime
1616
import numpy as np
1717
from pandas.types.common import (is_datetime64_dtype, is_timedelta64_dtype)
@@ -90,7 +90,7 @@ def cut(x, bins, right=True, labels=None, retbins=False, precision=3,
9090
x = x.view(np.int64)
9191
dtype = np.timedelta64
9292

93-
if is_datetime64_dtype(x):
93+
elif is_datetime64_dtype(x):
9494
x = x.view(np.int64)
9595
dtype = np.datetime64
9696

@@ -184,7 +184,7 @@ def qcut(x, q, labels=None, retbins=False, precision=3):
184184
x = x.view(np.int64)
185185
dtype = np.timedelta64
186186

187-
if is_datetime64_dtype(x):
187+
elif is_datetime64_dtype(x):
188188
x = x.view(np.int64)
189189
dtype = np.datetime64
190190

0 commit comments

Comments
 (0)