|
8 | 8 | import pandas.util.testing as tm |
9 | 9 | from pandas.compat import lrange |
10 | 10 | from pandas.compat.numpy import np_datetime64_compat |
11 | | -from pandas import (DatetimeIndex, Index, date_range, Series, DataFrame, |
| 11 | +from pandas import (DatetimeIndex, Index, date_range, DataFrame, |
12 | 12 | Timestamp, datetime, offsets) |
13 | 13 |
|
14 | | -from pandas.util.testing import assert_series_equal, assert_almost_equal |
| 14 | +from pandas.util.testing import assert_almost_equal |
15 | 15 |
|
16 | 16 | randn = np.random.randn |
17 | 17 |
|
@@ -223,22 +223,6 @@ def test_append_join_nondatetimeindex(self): |
223 | 223 | # it works |
224 | 224 | rng.join(idx, how='outer') |
225 | 225 |
|
226 | | - def test_to_period_nofreq(self): |
227 | | - idx = DatetimeIndex(['2000-01-01', '2000-01-02', '2000-01-04']) |
228 | | - pytest.raises(ValueError, idx.to_period) |
229 | | - |
230 | | - idx = DatetimeIndex(['2000-01-01', '2000-01-02', '2000-01-03'], |
231 | | - freq='infer') |
232 | | - assert idx.freqstr == 'D' |
233 | | - expected = pd.PeriodIndex(['2000-01-01', '2000-01-02', |
234 | | - '2000-01-03'], freq='D') |
235 | | - tm.assert_index_equal(idx.to_period(), expected) |
236 | | - |
237 | | - # GH 7606 |
238 | | - idx = DatetimeIndex(['2000-01-01', '2000-01-02', '2000-01-03']) |
239 | | - assert idx.freqstr is None |
240 | | - tm.assert_index_equal(idx.to_period(), expected) |
241 | | - |
242 | 226 | def test_comparisons_coverage(self): |
243 | 227 | rng = date_range('1/1/2000', periods=10) |
244 | 228 |
|
@@ -567,13 +551,6 @@ def test_does_not_convert_mixed_integer(self): |
567 | 551 | assert cols.dtype == joined.dtype |
568 | 552 | tm.assert_numpy_array_equal(cols.values, joined.values) |
569 | 553 |
|
570 | | - def test_slice_keeps_name(self): |
571 | | - # GH4226 |
572 | | - st = pd.Timestamp('2013-07-01 00:00:00', tz='America/Los_Angeles') |
573 | | - et = pd.Timestamp('2013-07-02 00:00:00', tz='America/Los_Angeles') |
574 | | - dr = pd.date_range(st, et, freq='H', name='timebucket') |
575 | | - assert dr[1:].name == dr.name |
576 | | - |
577 | 554 | def test_join_self(self): |
578 | 555 | index = date_range('1/1/2000', periods=10) |
579 | 556 | kinds = 'outer', 'inner', 'left', 'right' |
@@ -687,59 +664,3 @@ def test_factorize_dst(self): |
687 | 664 | arr, res = obj.factorize() |
688 | 665 | tm.assert_numpy_array_equal(arr, np.arange(12, dtype=np.intp)) |
689 | 666 | tm.assert_index_equal(res, idx) |
690 | | - |
691 | | - def test_slice_with_negative_step(self): |
692 | | - ts = Series(np.arange(20), |
693 | | - date_range('2014-01-01', periods=20, freq='MS')) |
694 | | - SLC = pd.IndexSlice |
695 | | - |
696 | | - def assert_slices_equivalent(l_slc, i_slc): |
697 | | - assert_series_equal(ts[l_slc], ts.iloc[i_slc]) |
698 | | - assert_series_equal(ts.loc[l_slc], ts.iloc[i_slc]) |
699 | | - assert_series_equal(ts.loc[l_slc], ts.iloc[i_slc]) |
700 | | - |
701 | | - assert_slices_equivalent(SLC[Timestamp('2014-10-01')::-1], SLC[9::-1]) |
702 | | - assert_slices_equivalent(SLC['2014-10-01'::-1], SLC[9::-1]) |
703 | | - |
704 | | - assert_slices_equivalent(SLC[:Timestamp('2014-10-01'):-1], SLC[:8:-1]) |
705 | | - assert_slices_equivalent(SLC[:'2014-10-01':-1], SLC[:8:-1]) |
706 | | - |
707 | | - assert_slices_equivalent(SLC['2015-02-01':'2014-10-01':-1], |
708 | | - SLC[13:8:-1]) |
709 | | - assert_slices_equivalent(SLC[Timestamp('2015-02-01'):Timestamp( |
710 | | - '2014-10-01'):-1], SLC[13:8:-1]) |
711 | | - assert_slices_equivalent(SLC['2015-02-01':Timestamp('2014-10-01'):-1], |
712 | | - SLC[13:8:-1]) |
713 | | - assert_slices_equivalent(SLC[Timestamp('2015-02-01'):'2014-10-01':-1], |
714 | | - SLC[13:8:-1]) |
715 | | - |
716 | | - assert_slices_equivalent(SLC['2014-10-01':'2015-02-01':-1], SLC[:0]) |
717 | | - |
718 | | - def test_slice_with_zero_step_raises(self): |
719 | | - ts = Series(np.arange(20), |
720 | | - date_range('2014-01-01', periods=20, freq='MS')) |
721 | | - tm.assert_raises_regex(ValueError, 'slice step cannot be zero', |
722 | | - lambda: ts[::0]) |
723 | | - tm.assert_raises_regex(ValueError, 'slice step cannot be zero', |
724 | | - lambda: ts.loc[::0]) |
725 | | - tm.assert_raises_regex(ValueError, 'slice step cannot be zero', |
726 | | - lambda: ts.loc[::0]) |
727 | | - |
728 | | - def test_slice_bounds_empty(self): |
729 | | - # GH 14354 |
730 | | - empty_idx = DatetimeIndex(freq='1H', periods=0, end='2015') |
731 | | - |
732 | | - right = empty_idx._maybe_cast_slice_bound('2015-01-02', 'right', 'loc') |
733 | | - exp = Timestamp('2015-01-02 23:59:59.999999999') |
734 | | - assert right == exp |
735 | | - |
736 | | - left = empty_idx._maybe_cast_slice_bound('2015-01-02', 'left', 'loc') |
737 | | - exp = Timestamp('2015-01-02 00:00:00') |
738 | | - assert left == exp |
739 | | - |
740 | | - def test_slice_duplicate_monotonic(self): |
741 | | - # https://github.com/pandas-dev/pandas/issues/16515 |
742 | | - idx = pd.DatetimeIndex(['2017', '2017']) |
743 | | - result = idx._maybe_cast_slice_bound('2017-01-01', 'left', 'loc') |
744 | | - expected = Timestamp('2017-01-01') |
745 | | - assert result == expected |
0 commit comments