File tree 3 files changed +15
-2
lines changed
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
229
229
- fixed handling of rolling_corr with center=True which could produce corr>1 (GH3155 _)
230
230
- Fixed issues where indices can be passed as 'index/column' in addition to 0/1 for the axis parameter
231
231
- PeriodIndex.tolist now boxes to Period (GH3178 _)
232
+ - PeriodIndex.get_loc KeyError now reports Period instead of ordinal (GH3179 _)
232
233
233
234
.. _GH622 : https://github.com/pydata/pandas/issues/622
234
235
.. _GH797 : https://github.com/pydata/pandas/issues/797
@@ -303,6 +304,7 @@ pandas 0.11.0
303
304
.. _GH3094 : https://github.com/pydata/pandas/issues/3094
304
305
.. _GH3130 : https://github.com/pydata/pandas/issues/3130
305
306
.. _GH3178 : https://github.com/pydata/pandas/issues/3178
307
+ .. _GH3179 : https://github.com/pydata/pandas/issues/3179
306
308
307
309
pandas 0.10.1
308
310
=============
Original file line number Diff line number Diff line change @@ -887,8 +887,11 @@ def get_loc(self, key):
887
887
except TypeError :
888
888
pass
889
889
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 ))
892
895
893
896
def slice_locs (self , start = None , end = None ):
894
897
"""
Original file line number Diff line number Diff line change @@ -1926,6 +1926,14 @@ def test_to_datetime_1703(self):
1926
1926
result = index .to_datetime ()
1927
1927
self .assertEquals (result [0 ], Timestamp ('1/1/2012' ))
1928
1928
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
+
1929
1937
def test_append_concat (self ):
1930
1938
# #1815
1931
1939
d1 = date_range ('12/31/1990' , '12/31/1999' , freq = 'A-DEC' )
You can’t perform that action at this time.
0 commit comments