Skip to content

Commit fa3aad7

Browse files
committed
simplify
1 parent dcf0c22 commit fa3aad7

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

pandas/tests/io/test_stata.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -897,14 +897,13 @@ def test_big_dates(self, datapath):
897897
expected[5][5] = expected[5][6] = datetime(1678, 1, 1)
898898

899899
expected = DataFrame(expected, columns=columns, dtype=object)
900-
# FIXME(GH#55564): can't astype directly to ms or s
901-
expected["date_tc"] = expected["date_tc"].astype("Period[ms]")._values.view("M8[ms]")
902-
expected["date_td"] = expected["date_td"].astype("Period[s]")._values.view("M8[s]")
903-
expected["date_tm"] = expected["date_tm"].astype("Period[s]")._values.view("M8[s]")
904-
expected["date_tw"] = expected["date_tw"].astype("Period[s]")._values.view("M8[s]")
905-
expected["date_tq"] = expected["date_tq"].astype("Period[s]")._values.view("M8[s]")
906-
expected["date_th"] = expected["date_th"].astype("Period[s]")._values.view("M8[s]")
907-
expected["date_ty"] = expected["date_ty"].astype("Period[s]")._values.view("M8[s]")
900+
expected["date_tc"] = expected["date_tc"].astype("M8[ms]")
901+
expected["date_td"] = expected["date_td"].astype("M8[s]")
902+
expected["date_tm"] = expected["date_tm"].astype("M8[s]")
903+
expected["date_tw"] = expected["date_tw"].astype("M8[s]")
904+
expected["date_tq"] = expected["date_tq"].astype("M8[s]")
905+
expected["date_th"] = expected["date_th"].astype("M8[s]")
906+
expected["date_ty"] = expected["date_ty"].astype("M8[s]")
908907

909908
parsed_115 = read_stata(datapath("io", "data", "stata", "stata9_115.dta"))
910909
parsed_117 = read_stata(datapath("io", "data", "stata", "stata9_117.dta"))
@@ -931,9 +930,7 @@ def test_dtype_conversion(self, datapath):
931930
expected["long_"] = expected["long_"].astype(np.int32)
932931
expected["float_"] = expected["float_"].astype(np.float32)
933932
expected["double_"] = expected["double_"].astype(np.float64)
934-
# FIXME(GH#55564): can't astype directly to M8[ms] without OutOfBoundsDatetime
935-
parr = expected["date_td"].astype("Period[D]")._values
936-
expected["date_td"] = parr.view("M8[D]").astype("M8[s]")
933+
expected["date_td"] = expected["date_td"].astype("M8[s]")
937934

938935
no_conversion = read_stata(
939936
datapath("io", "data", "stata", "stata6_117.dta"), convert_dates=True

0 commit comments

Comments
 (0)