Skip to content

Commit 9a2276f

Browse files
authored
TST: Test series construct of dtype timedelta64 pandas-dev#35465 (pandas-dev#47801)
* TST GH35465 Tests for repr of Series with dtype timedelta64 * pre commit test file * TST GH35465 Tests for Series constructs with dtype timedelta64 * restore pandas/tests/series/test_repr.py * perform pre-commit * use int64 for tests
1 parent fbf1681 commit 9a2276f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pandas/tests/series/test_constructors.py

+22
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,28 @@ def test_constructor_bool_dtype_missing_values(self):
18791879
expected = Series(True, index=[0], dtype="bool")
18801880
tm.assert_series_equal(result, expected)
18811881

1882+
def test_constructor_dtype_timedelta_alternative_construct(self):
1883+
# GH#35465
1884+
result = Series([1000000, 200000, 3000000], dtype="timedelta64[ns]")
1885+
expected = Series(pd.to_timedelta([1000000, 200000, 3000000], unit="ns"))
1886+
tm.assert_series_equal(result, expected)
1887+
1888+
def test_constructor_dtype_timedelta_ns_s(self):
1889+
# GH#35465
1890+
result = Series([1000000, 200000, 3000000], dtype="timedelta64[ns]")
1891+
expected = Series([1000000, 200000, 3000000], dtype="timedelta64[s]")
1892+
tm.assert_series_equal(result, expected)
1893+
1894+
def test_constructor_dtype_timedelta_ns_s_astype_int64(self):
1895+
# GH#35465
1896+
result = Series([1000000, 200000, 3000000], dtype="timedelta64[ns]").astype(
1897+
"int64"
1898+
)
1899+
expected = Series([1000000, 200000, 3000000], dtype="timedelta64[s]").astype(
1900+
"int64"
1901+
)
1902+
tm.assert_series_equal(result, expected)
1903+
18821904
@pytest.mark.filterwarnings(
18831905
"ignore:elementwise comparison failed:DeprecationWarning"
18841906
)

0 commit comments

Comments
 (0)