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

Method test_datetime_likes

pandas/tests/test_algos.py:1566–1646  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1564 tm.assert_series_equal(res_false, Series(exp_false))
1565
1566 def test_datetime_likes(self):
1567 dt = [
1568 "2011-01-01",
1569 "2011-01-02",
1570 "2011-01-01",
1571 "NaT",
1572 "2011-01-03",
1573 "2011-01-02",
1574 "2011-01-04",
1575 "2011-01-01",
1576 "NaT",
1577 "2011-01-06",
1578 ]
1579 td = [
1580 "1 days",
1581 "2 days",
1582 "1 days",
1583 "NaT",
1584 "3 days",
1585 "2 days",
1586 "4 days",
1587 "1 days",
1588 "NaT",
1589 "6 days",
1590 ]
1591
1592 cases = [
1593 np.array([Timestamp(d) for d in dt]),
1594 np.array([Timestamp(d, tz="US/Eastern") for d in dt]),
1595 np.array([Period(d, freq="D") for d in dt]),
1596 np.array([np.datetime64(d, "ns") for d in dt]),
1597 np.array([Timedelta(d) for d in td]),
1598 ]
1599
1600 exp_first = np.array(
1601 [False, False, True, False, False, True, False, True, True, False]
1602 )
1603 exp_last = np.array(
1604 [True, True, True, True, False, False, False, False, False, False]
1605 )
1606 exp_false = exp_first | exp_last
1607
1608 for case in cases:
1609 res_first = algos.duplicated(case, keep="first")
1610 tm.assert_numpy_array_equal(res_first, exp_first)
1611
1612 res_last = algos.duplicated(case, keep="last")
1613 tm.assert_numpy_array_equal(res_last, exp_last)
1614
1615 res_false = algos.duplicated(case, keep=False)
1616 tm.assert_numpy_array_equal(res_false, exp_false)
1617
1618 # index
1619 for idx in [
1620 Index(case),
1621 Index(case, dtype="category"),
1622 Index(case, dtype=object),
1623 ]:

Callers

nothing calls this directly

Calls 4

IndexClass · 0.90
SeriesClass · 0.90
arrayMethod · 0.45
duplicatedMethod · 0.45

Tested by

no test coverage detected