Пример #1
0
    def __eq__(self, other: Any) -> bool:
        if isinstance(other, str):
            if other.startswith("M8["):
                other = "datetime64[" + other[3:]
            return other == self.name

        return (isinstance(other, DatetimeTZDtype) and self.unit == other.unit
                and tz_compare(self.tz, other.tz))
Пример #2
0
    def test_non_nano(self, unit, reso, dtype):
        arr = np.arange(5, dtype=np.int64).view(f"M8[{unit}]")
        dta = DatetimeArray._simple_new(arr, dtype=dtype)

        assert dta.dtype == dtype
        assert dta[0]._reso == reso
        assert tz_compare(dta.tz, dta[0].tz)
        assert (dta[0] == dta[:1]).all()
Пример #3
0
def test_maybe_promote_datetimetz_with_datetimetz(tz_aware_fixture, tz_aware_fixture2):
    dtype = DatetimeTZDtype(tz=tz_aware_fixture)
    fill_dtype = DatetimeTZDtype(tz=tz_aware_fixture2)

    # create array of given dtype; casts "1" to correct dtype
    fill_value = pd.Series([10 ** 9], dtype=fill_dtype)[0]

    # filling datetimetz with datetimetz casts to object, unless tz matches
    exp_val_for_scalar = fill_value
    if tz_compare(dtype.tz, fill_dtype.tz):
        expected_dtype = dtype
    else:
        expected_dtype = np.dtype(object)

    _check_promote(dtype, fill_value, expected_dtype, exp_val_for_scalar)