|
1 | 1 | """ test to_datetime """
|
2 | 2 |
|
3 | 3 | import calendar
|
| 4 | +from collections import deque |
4 | 5 | from datetime import datetime, time
|
5 | 6 | import locale
|
6 | 7 |
|
@@ -838,7 +839,7 @@ def test_datetime_invalid_index(self, values, format, infer):
|
838 | 839 |
|
839 | 840 | @pytest.mark.parametrize("utc", [True, None])
|
840 | 841 | @pytest.mark.parametrize("format", ["%Y%m%d %H:%M:%S", None])
|
841 |
| - @pytest.mark.parametrize("constructor", [list, tuple, np.array, pd.Index]) |
| 842 | + @pytest.mark.parametrize("constructor", [list, tuple, np.array, pd.Index, deque]) |
842 | 843 | def test_to_datetime_cache(self, utc, format, constructor):
|
843 | 844 | date = "20130101 00:00:00"
|
844 | 845 | test_dates = [date] * 10 ** 5
|
@@ -2239,6 +2240,26 @@ def test_should_cache(listlike, do_caching):
|
2239 | 2240 | )
|
2240 | 2241 |
|
2241 | 2242 |
|
| 2243 | +@pytest.mark.parametrize( |
| 2244 | + "listlike", |
| 2245 | + [ |
| 2246 | + (deque([pd.Timestamp("2010-06-02 09:30:00")] * 51)), |
| 2247 | + ([pd.Timestamp("2010-06-02 09:30:00")] * 51), |
| 2248 | + (tuple([pd.Timestamp("2010-06-02 09:30:00")] * 51)), |
| 2249 | + ], |
| 2250 | +) |
| 2251 | +def test_no_slicing_errors_in_should_cache(listlike): |
| 2252 | + # GH 29403 |
| 2253 | + assert tools.should_cache(listlike) is True |
| 2254 | + |
| 2255 | + |
| 2256 | +def test_to_datetime_from_deque(): |
| 2257 | + # GH 29403 |
| 2258 | + result = pd.to_datetime(deque([pd.Timestamp("2010-06-02 09:30:00")] * 51)) |
| 2259 | + expected = pd.to_datetime([pd.Timestamp("2010-06-02 09:30:00")] * 51) |
| 2260 | + tm.assert_index_equal(result, expected) |
| 2261 | + |
| 2262 | + |
2242 | 2263 | @pytest.mark.parametrize(
|
2243 | 2264 | "unique_share,check_count, err_message",
|
2244 | 2265 | [
|
|
0 commit comments