File tree 3 files changed +9
-6
lines changed
3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -211,11 +211,7 @@ Bug Fixes
211
211
212
212
213
213
214
-
215
-
216
-
217
-
218
-
214
+ - Bug in invalid attribute access on a ``TimedeltaIndex`` incorrectly raised ``ValueError`` instead of ``AttributeError`` (:issue:`9680`)
219
215
220
216
221
217
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ def __contains__(self, key):
67
67
try :
68
68
res = self .get_loc (key )
69
69
return np .isscalar (res ) or type (res ) == slice or np .any (res )
70
- except (KeyError , TypeError ):
70
+ except (KeyError , TypeError , ValueError ):
71
71
return False
72
72
73
73
@property
Original file line number Diff line number Diff line change @@ -745,6 +745,13 @@ def test_nonunique_contains(self):
745
745
['00:01:00' , '00:01:00' , '00:00:01' ])):
746
746
tm .assertIn (idx [0 ], idx )
747
747
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
+
748
755
749
756
class TestPeriodIndexOps (Ops ):
750
757
You can’t perform that action at this time.
0 commit comments