1212from pandas .core .algorithms import quantile
1313from pandas .tools .tile import cut , qcut
1414import pandas .tools .tile as tmod
15- from pandas import to_datetime
15+ from pandas import to_datetime , DatetimeIndex
1616
1717
1818class 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
321331def curpath ():
0 commit comments