|
5 | 5 | import pytest
|
6 | 6 |
|
7 | 7 | import pandas as pd
|
8 |
| -from pandas import DataFrame, DatetimeIndex, Index, NaT, Timestamp, date_range, offsets |
| 8 | +from pandas import DataFrame, DatetimeIndex, Index, Timestamp, date_range, offsets |
9 | 9 | import pandas._testing as tm
|
10 | 10 |
|
11 | 11 | randn = np.random.randn
|
12 | 12 |
|
13 | 13 |
|
14 | 14 | class TestDatetimeIndex:
|
15 |
| - def test_roundtrip_pickle_with_tz(self): |
16 |
| - |
17 |
| - # GH 8367 |
18 |
| - # round-trip of timezone |
19 |
| - index = date_range("20130101", periods=3, tz="US/Eastern", name="foo") |
20 |
| - unpickled = tm.round_trip_pickle(index) |
21 |
| - tm.assert_index_equal(index, unpickled) |
22 |
| - |
23 |
| - def test_pickle(self): |
24 |
| - |
25 |
| - # GH#4606 |
26 |
| - p = tm.round_trip_pickle(NaT) |
27 |
| - assert p is NaT |
28 |
| - |
29 |
| - idx = pd.to_datetime(["2013-01-01", NaT, "2014-01-06"]) |
30 |
| - idx_p = tm.round_trip_pickle(idx) |
31 |
| - assert idx_p[0] == idx[0] |
32 |
| - assert idx_p[1] is NaT |
33 |
| - assert idx_p[2] == idx[2] |
34 |
| - |
35 |
| - # GH#11002 |
36 |
| - # don't infer freq |
37 |
| - idx = date_range("1750-1-1", "2050-1-1", freq="7D") |
38 |
| - idx_p = tm.round_trip_pickle(idx) |
39 |
| - tm.assert_index_equal(idx, idx_p) |
40 |
| - |
41 |
| - def test_pickle_after_set_freq(self): |
42 |
| - dti = date_range("20130101", periods=3, tz="US/Eastern", name="foo") |
43 |
| - dti = dti._with_freq(None) |
44 |
| - |
45 |
| - res = tm.round_trip_pickle(dti) |
46 |
| - tm.assert_index_equal(res, dti) |
47 |
| - |
48 | 15 | def test_reindex_preserves_tz_if_target_is_empty_list_or_array(self):
|
49 | 16 | # GH7774
|
50 | 17 | index = date_range("20130101", periods=3, tz="US/Eastern")
|
@@ -164,23 +131,6 @@ def test_append_nondatetimeindex(self):
|
164 | 131 | result = rng.append(idx)
|
165 | 132 | assert isinstance(result[0], Timestamp)
|
166 | 133 |
|
167 |
| - def test_map(self): |
168 |
| - rng = date_range("1/1/2000", periods=10) |
169 |
| - |
170 |
| - f = lambda x: x.strftime("%Y%m%d") |
171 |
| - result = rng.map(f) |
172 |
| - exp = Index([f(x) for x in rng], dtype="<U8") |
173 |
| - tm.assert_index_equal(result, exp) |
174 |
| - |
175 |
| - def test_map_fallthrough(self, capsys): |
176 |
| - # GH#22067, check we don't get warnings about silently ignored errors |
177 |
| - dti = date_range("2017-01-01", "2018-01-01", freq="B") |
178 |
| - |
179 |
| - dti.map(lambda x: pd.Period(year=x.year, month=x.month, freq="M")) |
180 |
| - |
181 |
| - captured = capsys.readouterr() |
182 |
| - assert captured.err == "" |
183 |
| - |
184 | 134 | def test_iteration_preserves_tz(self):
|
185 | 135 | # see gh-8890
|
186 | 136 | index = date_range("2012-01-01", periods=3, freq="H", tz="US/Eastern")
|
@@ -264,14 +214,6 @@ def test_sort_values(self):
|
264 | 214 | assert ordered[::-1].is_monotonic
|
265 | 215 | tm.assert_numpy_array_equal(dexer, np.array([0, 2, 1], dtype=np.intp))
|
266 | 216 |
|
267 |
| - def test_map_bug_1677(self): |
268 |
| - index = DatetimeIndex(["2012-04-25 09:30:00.393000"]) |
269 |
| - f = index.asof |
270 |
| - |
271 |
| - result = index.map(f) |
272 |
| - expected = Index([f(index[0])]) |
273 |
| - tm.assert_index_equal(result, expected) |
274 |
| - |
275 | 217 | def test_groupby_function_tuple_1677(self):
|
276 | 218 | df = DataFrame(np.random.rand(100), index=date_range("1/1/2000", periods=100))
|
277 | 219 | monthly_group = df.groupby(lambda x: (x.year, x.month))
|
@@ -454,18 +396,6 @@ def test_to_frame_datetime_tz(self):
|
454 | 396 | expected = DataFrame(idx, index=idx)
|
455 | 397 | tm.assert_frame_equal(result, expected)
|
456 | 398 |
|
457 |
| - @pytest.mark.parametrize("name", [None, "name"]) |
458 |
| - def test_index_map(self, name): |
459 |
| - # see GH20990 |
460 |
| - count = 6 |
461 |
| - index = pd.date_range("2018-01-01", periods=count, freq="M", name=name).map( |
462 |
| - lambda x: (x.year, x.month) |
463 |
| - ) |
464 |
| - exp_index = pd.MultiIndex.from_product( |
465 |
| - ((2018,), range(1, 7)), names=[name, name] |
466 |
| - ) |
467 |
| - tm.assert_index_equal(index, exp_index) |
468 |
| - |
469 | 399 | def test_split_non_utc(self):
|
470 | 400 | # GH 14042
|
471 | 401 | indices = pd.date_range("2016-01-01 00:00:00+0200", freq="S", periods=10)
|
|
0 commit comments