예제 #1
0
    def test_equals(self):
        # GH 13107
        idx = DatetimeIndex(["2011-01-01", "2011-01-02", "NaT"])
        assert idx.equals(idx)
        assert idx.equals(idx.copy())
        assert idx.equals(idx.astype(object))
        assert idx.astype(object).equals(idx)
        assert idx.astype(object).equals(idx.astype(object))
        assert not idx.equals(list(idx))
        assert not idx.equals(Series(idx))

        idx2 = DatetimeIndex(["2011-01-01", "2011-01-02", "NaT"],
                             tz="US/Pacific")
        assert not idx.equals(idx2)
        assert not idx.equals(idx2.copy())
        assert not idx.equals(idx2.astype(object))
        assert not idx.astype(object).equals(idx2)
        assert not idx.equals(list(idx2))
        assert not idx.equals(Series(idx2))

        # same internal, different tz
        idx3 = DatetimeIndex(idx.asi8, tz="US/Pacific")
        tm.assert_numpy_array_equal(idx.asi8, idx3.asi8)
        assert not idx.equals(idx3)
        assert not idx.equals(idx3.copy())
        assert not idx.equals(idx3.astype(object))
        assert not idx.astype(object).equals(idx3)
        assert not idx.equals(list(idx3))
        assert not idx.equals(Series(idx3))

        # check that we do not raise when comparing with OutOfBounds objects
        oob = Index([datetime(2500, 1, 1)] * 3, dtype=object)
        assert not idx.equals(oob)
        assert not idx2.equals(oob)
        assert not idx3.equals(oob)

        # check that we do not raise when comparing with OutOfBounds dt64
        oob2 = oob.map(np.datetime64)
        assert not idx.equals(oob2)
        assert not idx2.equals(oob2)
        assert not idx3.equals(oob2)
예제 #2
0
 def test_is_(self):
     dti = DatetimeIndex(start='1/1/2005', end='12/1/2005', freq='M')
     assert dti.is_(dti)
     assert dti.is_(dti.view())
     assert not dti.is_(dti.copy())
예제 #3
0
 def test_asfreq_datetimeindex_empty(self, frame_or_series):
     # GH#14320
     index = DatetimeIndex(["2016-09-29 11:00"])
     expected = frame_or_series(index=index, dtype=object).asfreq("H")
     result = frame_or_series([3], index=index.copy()).asfreq("H")
     tm.assert_index_equal(expected.index, result.index)
예제 #4
0
 def test_is_(self):
     dti = DatetimeIndex(start='1/1/2005', end='12/1/2005', freq='M')
     self.assertTrue(dti.is_(dti))
     self.assertTrue(dti.is_(dti.view()))
     self.assertFalse(dti.is_(dti.copy()))
예제 #5
0
 def test_is_(self):
     dti = DatetimeIndex(start='1/1/2005', end='12/1/2005', freq='M')
     assert dti.is_(dti)
     assert dti.is_(dti.view())
     assert not dti.is_(dti.copy())
예제 #6
0
 def test_is_(self):
     dti = DatetimeIndex(start='1/1/2005', end='12/1/2005', freq='M')
     self.assertTrue(dti.is_(dti))
     self.assertTrue(dti.is_(dti.view()))
     self.assertFalse(dti.is_(dti.copy()))