Skip to content

Commit d69350d

Browse files
committed
added test func test_groupby_any_timedelta_with_all_nulls()
1 parent c5c67dd commit d69350d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/groupby/test_grouping.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,3 +1180,15 @@ def test_grouping_by_key_is_in_axis():
11801180
result = gb.sum()
11811181
expected = DataFrame({"a": [1, 2], "b": [1, 2], "c": [7, 5]})
11821182
tm.assert_frame_equal(result, expected)
1183+
1184+
def test_groupby_any_timedelta_with_all_nulls():
1185+
# Create a DataFrame with timedelta values, including NaT (null timedelta)
1186+
df = pd.DataFrame({
1187+
'timedelta': [pd.Timedelta(days=1), pd.NaT],
1188+
'group': [0, 1]
1189+
})
1190+
result = df.groupby('group')['timedelta'].any()
1191+
1192+
# Expected behavior: group 1 should return False because it has all null values
1193+
expected = pd.Series([True, False], index=[0, 1])
1194+
pd.testing.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)