Skip to content

Commit de954f7

Browse files
committed
TST: Add test for TypeError in DataFrame.cov with NaT and Timedelta inputs
1 parent bda0025 commit de954f7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

pandas/tests/frame/test_reductions.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,39 @@ def test_df_empty_nullable_min_count_1(self, opname, dtype, exp_dtype):
19071907
expected = Series([pd.NA, pd.NA], dtype=exp_dtype, index=Index([0, 1]))
19081908
tm.assert_series_equal(result, expected)
19091909

1910+
@pytest.mark.parametrize(
1911+
"data",
1912+
[
1913+
{"a": [0, 1, 2], "b": [pd.NaT, pd.NaT, pd.NaT]},
1914+
{"a": [0, 1, 2], "b": [Timestamp("1990-01-01"), pd.NaT, pd.NaT]},
1915+
{
1916+
"a": [0, 1, 2],
1917+
"b": [
1918+
Timestamp("1990-01-01"),
1919+
Timestamp("1991-01-01"),
1920+
Timestamp("1992-01-01"),
1921+
],
1922+
},
1923+
{
1924+
"a": [0, 1, 2],
1925+
"b": [pd.Timedelta("1 days"), pd.Timedelta("2 days"), pd.NaT],
1926+
},
1927+
{
1928+
"a": [0, 1, 2],
1929+
"b": [
1930+
pd.Timedelta("1 days"),
1931+
pd.Timedelta("2 days"),
1932+
pd.Timedelta("3 days"),
1933+
],
1934+
},
1935+
],
1936+
)
1937+
def test_df_cov_pd_nat(self, data):
1938+
# GH #53115
1939+
df = DataFrame(data)
1940+
with pytest.raises(TypeError, match="not supported for cov"):
1941+
df.cov()
1942+
19101943

19111944
def test_sum_timedelta64_skipna_false():
19121945
# GH#17235

0 commit comments

Comments
 (0)