|
38 | 38 | import pandas.util.py3compat as py3compat
|
39 | 39 | from pandas.core.datetools import BDay
|
40 | 40 | import pandas.core.common as com
|
| 41 | +from pandas import concat |
41 | 42 |
|
42 | 43 | from numpy.testing.decorators import slow
|
43 | 44 |
|
@@ -171,7 +172,6 @@ def test_indexing_over_size_cutoff(self):
|
171 | 172 | def test_indexing_unordered(self):
|
172 | 173 |
|
173 | 174 | # GH 2437
|
174 |
| - from pandas import concat |
175 | 175 | rng = date_range(start='2011-01-01', end='2011-01-15')
|
176 | 176 | ts = Series(randn(len(rng)), index=rng)
|
177 | 177 | ts2 = concat([ts[0:4],ts[-4:],ts[4:-4]])
|
@@ -601,6 +601,26 @@ def test_to_datetime_unit(self):
|
601 | 601 | expected = Series([ Timestamp('2013-06-09 02:42:28') + timedelta(seconds=t) for t in range(20) ])
|
602 | 602 | assert_series_equal(result,expected)
|
603 | 603 |
|
| 604 | + s = Series([ epoch + t for t in range(20) ]).astype(float) |
| 605 | + result = to_datetime(s,unit='s') |
| 606 | + expected = Series([ Timestamp('2013-06-09 02:42:28') + timedelta(seconds=t) for t in range(20) ]) |
| 607 | + assert_series_equal(result,expected) |
| 608 | + |
| 609 | + s = Series([ epoch + t for t in range(20) ] + [iNaT]) |
| 610 | + result = to_datetime(s,unit='s') |
| 611 | + expected = Series([ Timestamp('2013-06-09 02:42:28') + timedelta(seconds=t) for t in range(20) ] + [NaT]) |
| 612 | + assert_series_equal(result,expected) |
| 613 | + |
| 614 | + s = Series([ epoch + t for t in range(20) ] + [iNaT]).astype(float) |
| 615 | + result = to_datetime(s,unit='s') |
| 616 | + expected = Series([ Timestamp('2013-06-09 02:42:28') + timedelta(seconds=t) for t in range(20) ] + [NaT]) |
| 617 | + assert_series_equal(result,expected) |
| 618 | + |
| 619 | + s = concat([Series([ epoch + t for t in range(20) ]).astype(float),Series([np.nan])],ignore_index=True) |
| 620 | + result = to_datetime(s,unit='s') |
| 621 | + expected = Series([ Timestamp('2013-06-09 02:42:28') + timedelta(seconds=t) for t in range(20) ] + [NaT]) |
| 622 | + assert_series_equal(result,expected) |
| 623 | + |
604 | 624 | def test_series_ctor_datetime64(self):
|
605 | 625 | rng = date_range('1/1/2000 00:00:00', '1/1/2000 1:59:50',
|
606 | 626 | freq='10s')
|
@@ -2741,6 +2761,19 @@ def check(val,unit=None,s=1,us=0):
|
2741 | 2761 | check(val/1000000.0 + 0.005,unit='ms',us=5)
|
2742 | 2762 | check(val/1000000000.0 + 0.5,unit='s',us=500000)
|
2743 | 2763 |
|
| 2764 | + # nan |
| 2765 | + result = Timestamp(np.nan) |
| 2766 | + self.assert_(result is NaT) |
| 2767 | + |
| 2768 | + result = Timestamp(None) |
| 2769 | + self.assert_(result is NaT) |
| 2770 | + |
| 2771 | + result = Timestamp(iNaT) |
| 2772 | + self.assert_(result is NaT) |
| 2773 | + |
| 2774 | + result = Timestamp(NaT) |
| 2775 | + self.assert_(result is NaT) |
| 2776 | + |
2744 | 2777 | def test_comparison(self):
|
2745 | 2778 | # 5-18-2012 00:00:00.000
|
2746 | 2779 | stamp = 1337299200000000000L
|
|
0 commit comments