Skip to content

Commit e2a622c

Browse files
authored
TST: resample does not yield empty groups (#10603) (#35799)
1 parent 8bf2bc4 commit e2a622c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/resample/test_timedelta.py

+15
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,18 @@ def test_resample_timedelta_edge_case(start, end, freq, resample_freq):
150150
tm.assert_index_equal(result.index, expected_index)
151151
assert result.index.freq == expected_index.freq
152152
assert not np.isnan(result[-1])
153+
154+
155+
def test_resample_with_timedelta_yields_no_empty_groups():
156+
# GH 10603
157+
df = pd.DataFrame(
158+
np.random.normal(size=(10000, 4)),
159+
index=pd.timedelta_range(start="0s", periods=10000, freq="3906250n"),
160+
)
161+
result = df.loc["1s":, :].resample("3s").apply(lambda x: len(x))
162+
163+
expected = pd.DataFrame(
164+
[[768.0] * 4] * 12 + [[528.0] * 4],
165+
index=pd.timedelta_range(start="1s", periods=13, freq="3s"),
166+
)
167+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)