Skip to content

Commit

Permalink
apply the review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tkmz-n committed Aug 20, 2020
1 parent 53252a0 commit a731549
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pandas/tests/resample/test_timedelta.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,16 @@ def test_resample_timedelta_edge_case(start, end, freq, resample_freq):
assert not np.isnan(result[-1])


def test_resample_timedelta_no_empty_groups():
def test_resample_with_timedelta_yields_no_empty_groups():
# GH 10603
# check that resample does not yield empty groups
df = pd.DataFrame(np.random.normal(size=(10000, 4)))
df.index = pd.timedelta_range(start="0s", periods=10000, freq="3906250n")
df = pd.DataFrame(
np.random.normal(size=(10000, 4)),
index=pd.timedelta_range(start="0s", periods=10000, freq="3906250n"),
)
result = df.loc["1s":, :].resample("3s").apply(lambda x: len(x))

expected = pd.DataFrame([[768.0] * 4] * 12 + [[528.0] * 4])
expected.index = pd.timedelta_range(start="1s", periods=13, freq="3s")
expected = pd.DataFrame(
[[768.0] * 4] * 12 + [[528.0] * 4],
index=pd.timedelta_range(start="1s", periods=13, freq="3s"),
)
tm.assert_frame_equal(result, expected)

0 comments on commit a731549

Please sign in to comment.