Skip to content

Commit be9b2fd

Browse files
committed
added test for datetime index
1 parent 71f6008 commit be9b2fd

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

pandas/tools/tests/test_tile.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from pandas.core.algorithms import quantile
1313
from pandas.tools.tile import cut, qcut
1414
import pandas.tools.tile as tmod
15-
from pandas import to_datetime
15+
from pandas import to_datetime, DatetimeIndex
1616

1717

1818
class TestCut(tm.TestCase):
@@ -303,7 +303,7 @@ def test_datetime_list_cut(self):
303303
'(2013-01-01 16:00:00, 2013-01-02 08:00:00]',
304304
'(2013-01-02 08:00:00, 2013-01-03 00:00:00]'],
305305
).astype("category", ordered=True)
306-
tm.assert_almost_equal(Series(result), expected)
306+
tm.assert_series_equal(Series(result), expected)
307307

308308
def test_datetime_ndarray_cut(self):
309309
# GH 14714
@@ -315,7 +315,17 @@ def test_datetime_ndarray_cut(self):
315315
'(2013-01-01 16:00:00, 2013-01-02 08:00:00]',
316316
'(2013-01-02 08:00:00, 2013-01-03 00:00:00]'],
317317
).astype("category", ordered=True)
318-
tm.assert_almost_equal(Series(result), expected)
318+
tm.assert_series_equal(Series(result), expected)
319+
320+
def test_datetime_index_cut(self):
321+
# GH 14714
322+
data = DatetimeIndex(['2013-01-01', '2013-01-02', '2013-01-03'])
323+
result, bins = cut(data, 3, retbins=True)
324+
expected = Series(['(2012-12-31 23:57:07.200000, 2013-01-01 16:00:00]',
325+
'(2013-01-01 16:00:00, 2013-01-02 08:00:00]',
326+
'(2013-01-02 08:00:00, 2013-01-03 00:00:00]'],
327+
).astype("category", ordered=True)
328+
tm.assert_series_equal(Series(result), expected)
319329

320330

321331
def curpath():

0 commit comments

Comments
 (0)