Skip to content

Commit 8cca6af

Browse files
Ajay SaxenaAjay Saxena
Ajay Saxena
authored and
Ajay Saxena
committed
added testcase for datetime cut
1 parent 797afb7 commit 8cca6af

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tools/tests/test_tile.py

+11
Original file line numberDiff line numberDiff line change
@@ -12,6 +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
1516

1617

1718
class TestCut(tm.TestCase):
@@ -283,6 +284,16 @@ def test_single_bin(self):
283284
result = cut(s, 1, labels=False)
284285
tm.assert_series_equal(result, expected)
285286

287+
def test_datetime_cut(self):
288+
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]')
296+
286297

287298
def curpath():
288299
pth, _ = os.path.split(os.path.abspath(__file__))

0 commit comments

Comments
 (0)