Skip to content

Commit 275c25a

Browse files
author
tp
committed
moved tests from TestAnnual to TestPivotTable
1 parent 9310f0f commit 275c25a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

pandas/tests/reshape/test_pivot.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,39 @@ def test_pivot_dtaccessor(self):
890890
index=['X', 'Y'], columns=exp_col)
891891
tm.assert_frame_equal(result, expected)
892892

893+
def test_daily(self):
894+
rng = date_range('1/1/2000', '12/31/2004', freq='D')
895+
ts = Series(np.random.randn(len(rng)), index=rng)
896+
897+
annual = pivot_table(DataFrame(ts), index=ts.index.year,
898+
columns=ts.index.dayofyear)
899+
annual.columns = annual.columns.droplevel(0)
900+
901+
doy = np.asarray(ts.index.dayofyear)
902+
903+
for i in range(1, 367):
904+
subset = ts[doy == i]
905+
subset.index = subset.index.year
906+
907+
result = annual[i].dropna()
908+
tm.assert_series_equal(result, subset, check_names=False)
909+
assert result.name == i
910+
911+
def test_monthly(self):
912+
rng = date_range('1/1/2000', '12/31/2004', freq='M')
913+
ts = Series(np.random.randn(len(rng)), index=rng)
914+
915+
annual = pivot_table(pd.DataFrame(ts), index=ts.index.year, columns=ts.index.month)
916+
annual.columns = annual.columns.droplevel(0)
917+
918+
month = ts.index.month
919+
for i in range(1, 13):
920+
subset = ts[month == i]
921+
subset.index = subset.index.year
922+
result = annual[i].dropna()
923+
tm.assert_series_equal(result, subset, check_names=False)
924+
assert result.name == i
925+
893926
def test_pivot_table_with_iterator_values(self):
894927
# GH 12017
895928
aggs = {'D': 'sum', 'E': 'mean'}

0 commit comments

Comments
 (0)