File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -313,3 +313,19 @@ def test_loc_setitem_with_existing_dst(self):
313313 columns = ['value' ],
314314 dtype = object )
315315 tm .assert_frame_equal (result , expected )
316+
317+ def test_loc_str_slicing (self ):
318+ ix = pd .period_range (start = '2017-01-01' , end = '2018-01-01' , freq = 'M' )
319+ ser = ix .to_series ()
320+ result = ser .loc [:"2017-12" ]
321+ expected = ser .iloc [:- 1 ]
322+
323+ tm .assert_series_equal (result , expected )
324+
325+ def test_loc_label_slicing (self ):
326+ ix = pd .period_range (start = '2017-01-01' , end = '2018-01-01' , freq = 'M' )
327+ ser = ix .to_series ()
328+ result = ser .loc [:ix [- 2 ]]
329+ expected = ser .iloc [:- 1 ]
330+
331+ tm .assert_series_equal (result , expected )
Original file line number Diff line number Diff line change @@ -95,3 +95,19 @@ def test_roundtrip_thru_setitem(self):
9595
9696 assert expected == result
9797 tm .assert_frame_equal (df , df_copy )
98+
99+ def test_loc_str_slicing (self ):
100+ ix = pd .timedelta_range (start = '1 day' , end = '2 days' , freq = '1H' )
101+ ser = ix .to_series ()
102+ result = ser .loc [:"1 days" ]
103+ expected = ser .iloc [:- 1 ]
104+
105+ tm .assert_series_equal (result , expected )
106+
107+ def test_loc_slicing (self ):
108+ ix = pd .timedelta_range (start = '1 day' , end = '2 days' , freq = '1H' )
109+ ser = ix .to_series ()
110+ result = ser .loc [:ix [- 2 ]]
111+ expected = ser .iloc [:- 1 ]
112+
113+ tm .assert_series_equal (result , expected )
You can’t perform that action at this time.
0 commit comments