8000 TST: resample does not yield empty groups (#10603) by tkmz-n · Pull Request #35799 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

TST: resample does not yield empty groups (#10603) #35799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 21, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
TST: resample does not yield empty groups (#10603)
  • Loading branch information
tkmz-n committed Aug 20, 2020
commit d7a392d8c9cb01af02bcf9502b6b32a7e585aa74
12 changes: 12 additions & 0 deletions pandas/tests/resample/test_timedelta.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,15 @@ def test_resample_timedelta_edge_case(start, end, freq, resample_freq):
tm.assert_index_equal(result.index, expected_index)
assert result.index.freq == expected_index.freq
assert not np.isnan(result[-1])


def test_resample_timedelta_no_empty_groups():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-pick: test_resample_with_timedelta_yields_no_empty_groups

Just to make it easier to tell what the test does if we see it failing

# GH 10603
# check that resample does not yield empty groups
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-pick: this comment is maybe spurious

df = pd.DataFrame(np.random.normal(size=(10000, 4)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define df in a single step: pd.DataFrame(..., index=...)

df.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])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

expected.index = pd.timedelta_range(start="1s", periods=13, freq="3s")
tm.assert_frame_equal(result, expected)
0