File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed
Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -211,11 +211,7 @@ Bug Fixes
211211
212212
213213
214-
215-
216-
217-
218-
214+ - Bug in invalid attribute access on a ``TimedeltaIndex`` incorrectly raised ``ValueError`` instead of ``AttributeError`` (:issue:`9680`)
219215
220216
221217
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ def __contains__(self, key):
6767 try :
6868 res = self .get_loc (key )
6969 return np .isscalar (res ) or type (res ) == slice or np .any (res )
70- except (KeyError , TypeError ):
70+ except (KeyError , TypeError , ValueError ):
7171 return False
7272
7373 @property
Original file line number Diff line number Diff line change @@ -745,6 +745,13 @@ def test_nonunique_contains(self):
745745 ['00:01:00' , '00:01:00' , '00:00:01' ])):
746746 tm .assertIn (idx [0 ], idx )
747747
748+ def test_unknown_attribute (self ):
749+ #GH 9680
750+ tdi = pd .timedelta_range (start = 0 ,periods = 10 ,freq = '1s' )
751+ ts = pd .Series (np .random .normal (size = 10 ),index = tdi )
752+ self .assertNotIn ('foo' ,ts .__dict__ .keys ())
753+ self .assertRaises (AttributeError ,lambda : ts .foo )
754+
748755
749756class TestPeriodIndexOps (Ops ):
750757
You can’t perform that action at this time.
0 commit comments