Skip to content

Commit 69cc851

Browse files
authored
TST #24444 added tests (#34627)
* TST #24444 added tests * TST #24444 added tests The test was modified according to review
1 parent 49888e0 commit 69cc851

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pandas/tests/scalar/period/test_period.py

+20
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,26 @@ def test_to_timestamp_business_end(self):
649649
expected = pd.Timestamp("1990-01-06") - pd.Timedelta(nanoseconds=1)
650650
assert result == expected
651651

652+
@pytest.mark.parametrize(
653+
"ts, expected",
654+
[
655+
("1970-01-01 00:00:00", 0),
656+
("1970-01-01 00:00:00.000001", 1),
657+
("1970-01-01 00:00:00.00001", 10),
658+
("1970-01-01 00:00:00.499", 499000),
659+
("1999-12-31 23:59:59.999", 999000),
660+
("1999-12-31 23:59:59.999999", 999999),
661+
("2050-12-31 23:59:59.5", 500000),
662+
("2050-12-31 23:59:59.500001", 500001),
663+
("2050-12-31 23:59:59.123456", 123456),
664+
],
665+
)
666+
@pytest.mark.parametrize("freq", [None, "us", "ns"])
667+
def test_to_timestamp_microsecond(self, ts, expected, freq):
668+
# GH 24444
669+
result = Period(ts).to_timestamp(freq=freq).microsecond
670+
assert result == expected
671+
652672
# --------------------------------------------------------------
653673
# Rendering: __repr__, strftime, etc
654674

0 commit comments

Comments
 (0)