@@ -890,6 +890,40 @@ def test_pivot_dtaccessor(self):
890
890
index = ['X' , 'Y' ], columns = exp_col )
891
891
tm .assert_frame_equal (result , expected )
892
892
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 ,
916
+ columns = ts .index .month )
917
+ annual .columns = annual .columns .droplevel (0 )
918
+
919
+ month = ts .index .month
920
+ for i in range (1 , 13 ):
921
+ subset = ts [month == i ]
922
+ subset .index = subset .index .year
923
+ result = annual [i ].dropna ()
924
+ tm .assert_series_equal (result , subset , check_names = False )
925
+ assert result .name == i
926
+
893
927
def test_pivot_table_with_iterator_values (self ):
894
928
# GH 12017
895
929
aggs = {'D' : 'sum' , 'E' : 'mean' }
0 commit comments