|
1 | | -from datetime import datetime |
2 | 1 | from io import StringIO |
3 | 2 |
|
4 | 3 | import numpy as np |
5 | | -import pytest |
6 | 4 |
|
7 | 5 | from pandas._libs.tslib import iNaT |
8 | 6 |
|
9 | 7 | import pandas as pd |
10 | | -from pandas import ( |
11 | | - DataFrame, |
12 | | - DatetimeIndex, |
13 | | - NaT, |
14 | | - Series, |
15 | | - Timestamp, |
16 | | - date_range, |
17 | | - timedelta_range, |
18 | | -) |
| 8 | +from pandas import DataFrame, DatetimeIndex, Series, date_range, timedelta_range |
19 | 9 | import pandas._testing as tm |
20 | 10 |
|
21 | 11 |
|
@@ -225,82 +215,6 @@ def test_asfreq_resample_set_correct_freq(self): |
225 | 215 | # does .resample() set .freq correctly? |
226 | 216 | assert df.resample("D").asfreq().index.freq == "D" |
227 | 217 |
|
228 | | - def test_pickle(self): |
229 | | - |
230 | | - # GH4606 |
231 | | - p = tm.round_trip_pickle(NaT) |
232 | | - assert p is NaT |
233 | | - |
234 | | - idx = pd.to_datetime(["2013-01-01", NaT, "2014-01-06"]) |
235 | | - idx_p = tm.round_trip_pickle(idx) |
236 | | - assert idx_p[0] == idx[0] |
237 | | - assert idx_p[1] is NaT |
238 | | - assert idx_p[2] == idx[2] |
239 | | - |
240 | | - # GH11002 |
241 | | - # don't infer freq |
242 | | - idx = date_range("1750-1-1", "2050-1-1", freq="7D") |
243 | | - idx_p = tm.round_trip_pickle(idx) |
244 | | - tm.assert_index_equal(idx, idx_p) |
245 | | - |
246 | | - @pytest.mark.parametrize("tz", [None, "Asia/Tokyo", "US/Eastern"]) |
247 | | - def test_setops_preserve_freq(self, tz): |
248 | | - rng = date_range("1/1/2000", "1/1/2002", name="idx", tz=tz) |
249 | | - |
250 | | - result = rng[:50].union(rng[50:100]) |
251 | | - assert result.name == rng.name |
252 | | - assert result.freq == rng.freq |
253 | | - assert result.tz == rng.tz |
254 | | - |
255 | | - result = rng[:50].union(rng[30:100]) |
256 | | - assert result.name == rng.name |
257 | | - assert result.freq == rng.freq |
258 | | - assert result.tz == rng.tz |
259 | | - |
260 | | - result = rng[:50].union(rng[60:100]) |
261 | | - assert result.name == rng.name |
262 | | - assert result.freq is None |
263 | | - assert result.tz == rng.tz |
264 | | - |
265 | | - result = rng[:50].intersection(rng[25:75]) |
266 | | - assert result.name == rng.name |
267 | | - assert result.freqstr == "D" |
268 | | - assert result.tz == rng.tz |
269 | | - |
270 | | - nofreq = DatetimeIndex(list(rng[25:75]), name="other") |
271 | | - result = rng[:50].union(nofreq) |
272 | | - assert result.name is None |
273 | | - assert result.freq == rng.freq |
274 | | - assert result.tz == rng.tz |
275 | | - |
276 | | - result = rng[:50].intersection(nofreq) |
277 | | - assert result.name is None |
278 | | - assert result.freq == rng.freq |
279 | | - assert result.tz == rng.tz |
280 | | - |
281 | | - def test_from_M8_structured(self): |
282 | | - dates = [(datetime(2012, 9, 9, 0, 0), datetime(2012, 9, 8, 15, 10))] |
283 | | - arr = np.array(dates, dtype=[("Date", "M8[us]"), ("Forecasting", "M8[us]")]) |
284 | | - df = DataFrame(arr) |
285 | | - |
286 | | - assert df["Date"][0] == dates[0][0] |
287 | | - assert df["Forecasting"][0] == dates[0][1] |
288 | | - |
289 | | - s = Series(arr["Date"]) |
290 | | - assert isinstance(s[0], Timestamp) |
291 | | - assert s[0] == dates[0][0] |
292 | | - |
293 | | - def test_get_level_values_box(self): |
294 | | - from pandas import MultiIndex |
295 | | - |
296 | | - dates = date_range("1/1/2000", periods=4) |
297 | | - levels = [dates, [0, 1]] |
298 | | - codes = [[0, 0, 1, 1, 2, 2, 3, 3], [0, 1, 0, 1, 0, 1, 0, 1]] |
299 | | - |
300 | | - index = MultiIndex(levels=levels, codes=codes) |
301 | | - |
302 | | - assert isinstance(index.get_level_values(0)[0], Timestamp) |
303 | | - |
304 | 218 | def test_view_tz(self): |
305 | 219 | # GH#24024 |
306 | 220 | ser = pd.Series(pd.date_range("2000", periods=4, tz="US/Central")) |
|
0 commit comments