MCPcopy
hub / github.com/pandas-dev/pandas / test_diff_datetimelike_nat

Method test_diff_datetimelike_nat

pandas/tests/test_algos.py:2042–2055  ·  view source on GitHub ↗
(self, dtype)

Source from the content-addressed store, hash-verified

2040class TestDiff:
2041 @pytest.mark.parametrize("dtype", ["M8[ns]", "m8[ns]"])
2042 def test_diff_datetimelike_nat(self, dtype):
2043 # NaT - NaT is NaT, not 0
2044 arr = np.arange(12).astype(np.int64).view(dtype).reshape(3, 4)
2045 arr[:, 2] = arr.dtype.type("NaT", "ns")
2046 result = algos.diff(arr, 1, axis=0)
2047
2048 expected = np.ones(arr.shape, dtype="timedelta64[ns]") * 4
2049 expected[:, 2] = np.timedelta64("NaT", "ns")
2050 expected[0, :] = np.timedelta64("NaT", "ns")
2051
2052 tm.assert_numpy_array_equal(result, expected)
2053
2054 result = algos.diff(arr.T, 1, axis=1)
2055 tm.assert_numpy_array_equal(result, expected.T)
2056
2057 def test_diff_ea_axis(self):
2058 dta = date_range("2016-01-01", periods=3, tz="US/Pacific")._data

Callers

nothing calls this directly

Calls 6

timedelta64Method · 0.80
reshapeMethod · 0.45
viewMethod · 0.45
astypeMethod · 0.45
typeMethod · 0.45
diffMethod · 0.45

Tested by

no test coverage detected