File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,7 @@ pandas 0.11.0
229229 - fixed handling of rolling_corr with center=True which could produce corr>1 (GH3155 _)
230230 - Fixed issues where indices can be passed as 'index/column' in addition to 0/1 for the axis parameter
231231 - PeriodIndex.tolist now boxes to Period (GH3178 _)
232+ - PeriodIndex.get_loc KeyError now reports Period instead of ordinal (GH3179 _)
232233
233234.. _GH622 : https://github.com/pydata/pandas/issues/622
234235.. _GH797 : https://github.com/pydata/pandas/issues/797
@@ -303,6 +304,7 @@ pandas 0.11.0
303304.. _GH3094 : https://github.com/pydata/pandas/issues/3094
304305.. _GH3130 : https://github.com/pydata/pandas/issues/3130
305306.. _GH3178 : https://github.com/pydata/pandas/issues/3178
307+ .. _GH3179 : https://github.com/pydata/pandas/issues/3179
306308
307309pandas 0.10.1
308310=============
Original file line number Diff line number Diff line change @@ -887,8 +887,11 @@ def get_loc(self, key):
887887 except TypeError :
888888 pass
889889
890- key = Period (key , self .freq ).ordinal
891- return self ._engine .get_loc (key )
890+ key = Period (key , self .freq )
891+ try :
892+ return self ._engine .get_loc (key .ordinal )
893+ except KeyError as inst :
894+ raise KeyError (repr (key ))
892895
893896 def slice_locs (self , start = None , end = None ):
894897 """
Original file line number Diff line number Diff line change @@ -1926,6 +1926,14 @@ def test_to_datetime_1703(self):
19261926 result = index .to_datetime ()
19271927 self .assertEquals (result [0 ], Timestamp ('1/1/2012' ))
19281928
1929+ def test_get_loc_msg (self ):
1930+ idx = period_range ('2000-1-1' , freq = 'A' , periods = 10 )
1931+ bad_period = Period ('2012' , 'A' )
1932+ try :
1933+ idx .get_loc (bad_period )
1934+ except KeyError as inst :
1935+ self .assert_ (inst .message == repr (bad_period ))
1936+
19291937 def test_append_concat (self ):
19301938 # #1815
19311939 d1 = date_range ('12/31/1990' , '12/31/1999' , freq = 'A-DEC' )
You can’t perform that action at this time.
0 commit comments