@@ -1836,6 +1836,37 @@ def test_concat_datetime_datetime64_frame(self):
1836
1836
# it works!
1837
1837
pd .concat ([df1 , df2_obj ])
1838
1838
1839
+ def test_period_resample (self ):
1840
+ # GH3609
1841
+ s = Series (range (100 ),index = date_range ('20130101' , freq = 's' , periods = 100 ), dtype = 'float' )
1842
+ s [10 :30 ] = np .nan
1843
+ expected = Series ([34.5 , 79.5 ], index = [Period ('2013-01-01 00:00' , 'T' ), Period ('2013-01-01 00:01' , 'T' )])
1844
+ result = s .to_period ().resample ('T' , kind = 'period' )
1845
+ assert_series_equal (result , expected )
1846
+ result2 = s .resample ('T' , kind = 'period' )
1847
+ assert_series_equal (result2 , expected )
1848
+
1849
+ def test_period_resample_with_local_timezone (self ):
1850
+ # GH5430
1851
+ _skip_if_no_pytz ()
1852
+ import pytz
1853
+
1854
+ local_timezone = pytz .timezone ('America/Los_Angeles' )
1855
+
1856
+ start = datetime (year = 2013 , month = 11 , day = 1 , hour = 0 , minute = 0 , tzinfo = pytz .utc )
1857
+ # 1 day later
1858
+ end = datetime (year = 2013 , month = 11 , day = 2 , hour = 0 , minute = 0 , tzinfo = pytz .utc )
1859
+
1860
+ index = pd .date_range (start , end , freq = 'H' )
1861
+
1862
+ series = pd .Series (1 , index = index )
1863
+ series = series .tz_convert (local_timezone )
1864
+ result = series .resample ('D' , kind = 'period' )
1865
+ # Create the expected series
1866
+ expected_index = (pd .period_range (start = start , end = end , freq = 'D' ) - 1 ) # Index is moved back a day with the timezone conversion from UTC to Pacific
1867
+ expected = pd .Series (1 , index = expected_index )
1868
+ assert_series_equal (result , expected )
1869
+
1839
1870
1840
1871
def _simple_ts (start , end , freq = 'D' ):
1841
1872
rng = date_range (start , end , freq = freq )
0 commit comments