|
4 | 4 | import numpy as np
|
5 | 5 | from numpy.random import RandomState
|
6 | 6 | from numpy import nan
|
7 |
| -import datetime |
| 7 | +from datetime import datetime |
8 | 8 | from pandas import Series, Categorical, CategoricalIndex, Index
|
9 | 9 | import pandas as pd
|
10 | 10 |
|
@@ -121,7 +121,7 @@ def test_mixed_integer(self):
|
121 | 121 |
|
122 | 122 | def test_unsortable(self):
|
123 | 123 | # GH 13714
|
124 |
| - arr = np.array([1, 2, datetime.datetime.now(), 0, 3], dtype=object) |
| 124 | + arr = np.array([1, 2, datetime.now(), 0, 3], dtype=object) |
125 | 125 | if compat.PY2 and not pd._np_version_under1p10:
|
126 | 126 | # RuntimeWarning: tp_compare didn't return -1 or -2 for exception
|
127 | 127 | with tm.assert_produces_warning(RuntimeWarning):
|
@@ -556,6 +556,18 @@ def test_value_counts_nat(self):
|
556 | 556 | tm.assert_series_equal(algos.value_counts(dt), exp_dt)
|
557 | 557 | # TODO same for (timedelta)
|
558 | 558 |
|
| 559 | + def test_value_counts_datetime_outofbounds(self): |
| 560 | + # GH 13663 |
| 561 | + s = pd.Series([datetime(3000, 1, 1), datetime(5000, 1, 1), |
| 562 | + datetime(5000, 1, 1), datetime(6000, 1, 1), |
| 563 | + datetime(3000, 1, 1), datetime(3000, 1, 1)]) |
| 564 | + res = s.value_counts() |
| 565 | + |
| 566 | + exp_index = pd.Index([datetime(3000, 1, 1), datetime(5000, 1, 1), |
| 567 | + datetime(6000, 1, 1)], dtype=object) |
| 568 | + exp = pd.Series([3, 2, 1], index=exp_index) |
| 569 | + tm.assert_series_equal(res, exp) |
| 570 | + |
559 | 571 | def test_categorical(self):
|
560 | 572 | s = Series(pd.Categorical(list('aaabbc')))
|
561 | 573 | result = s.value_counts()
|
@@ -818,7 +830,7 @@ def _check(arr):
|
818 | 830 | def test_pad_backfill_object_segfault():
|
819 | 831 |
|
820 | 832 | old = np.array([], dtype='O')
|
821 |
| - new = np.array([datetime.datetime(2010, 12, 31)], dtype='O') |
| 833 | + new = np.array([datetime(2010, 12, 31)], dtype='O') |
822 | 834 |
|
823 | 835 | result = _algos.pad_object(old, new)
|
824 | 836 | expected = np.array([-1], dtype=np.int64)
|
|
0 commit comments