Skip to content

Commit

Permalink
moved tests from TestAnnual to TestPivotTable
Browse files Browse the repository at this point in the history
  • Loading branch information
tp committed Nov 21, 2017
1 parent 9310f0f commit 275c25a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pandas/tests/reshape/test_pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,39 @@ def test_pivot_dtaccessor(self):
index=['X', 'Y'], columns=exp_col)
tm.assert_frame_equal(result, expected)

def test_daily(self):
rng = date_range('1/1/2000', '12/31/2004', freq='D')
ts = Series(np.random.randn(len(rng)), index=rng)

annual = pivot_table(DataFrame(ts), index=ts.index.year,
columns=ts.index.dayofyear)
annual.columns = annual.columns.droplevel(0)

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

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

def test_monthly(self):
rng = date_range('1/1/2000', '12/31/2004', freq='M')
ts = Series(np.random.randn(len(rng)), index=rng)

annual = pivot_table(pd.DataFrame(ts), index=ts.index.year, columns=ts.index.month)
annual.columns = annual.columns.droplevel(0)

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

def test_pivot_table_with_iterator_values(self):
# GH 12017
aggs = {'D': 'sum', 'E': 'mean'}
Expand Down

0 comments on commit 275c25a

Please sign in to comment.