Skip to content
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
15 changes: 7 additions & 8 deletions pandas/tests/reshape/test_pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1712,8 +1712,7 @@ def test_pivot_dtaccessor(self):
)
tm.assert_frame_equal(result, expected)

@pytest.mark.parametrize("i", range(1, 367))
def test_daily(self, i):
def test_daily(self):
rng = date_range("1/1/2000", "12/31/2004", freq="D")
ts = Series(np.random.default_rng(2).standard_normal(len(rng)), index=rng)

Expand All @@ -1724,12 +1723,12 @@ def test_daily(self, i):

doy = np.asarray(ts.index.dayofyear)

subset = ts[doy == i]
Copy link
Member

Choose a reason for hiding this comment

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

Honestly, it may be a better test to use tm.assert_frame_equal and compare this to an expected DataFrame (making the input have constant data)

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, that makes sense. updated

subset.index = subset.index.year

result = annual[i].dropna()
tm.assert_series_equal(result, subset, check_names=False)
assert result.name == i
for i in range(1, 367):
subset = ts[doy == i]
subset.index = subset.index.year
result = annual[i].dropna()
tm.assert_series_equal(result, subset, check_names=False)
assert result.name == i

@pytest.mark.parametrize("i", range(1, 13))
def test_monthly(self, i):
Expand Down