@@ -3812,38 +3812,51 @@ def _is_memory_usage_qualified(self):
3812
3812
def is_type_compatible (self , kind ):
3813
3813
return kind == self .inferred_type
3814
3814
3815
- _index_shared_docs ['__contains__ ' ] = """
3816
- Return a boolean if this key is IN the index.
3815
+ _index_shared_docs ['contains ' ] = """
3816
+ Return a boolean indicating whether the provided key is in the index.
3817
3817
3818
3818
Parameters
3819
3819
----------
3820
- key : object
3820
+ key : label
3821
+ The key to check if it is present in the index.
3821
3822
3822
3823
Returns
3823
3824
-------
3824
- boolean
3825
+ bool
3826
+ Whether the key search is in the index.
3827
+
3828
+ See Also
3829
+ --------
3830
+ Index.isin : Returns an ndarray of boolean dtype indicating whether the
3831
+ list-like key is in the index.
3832
+
3833
+ Examples
3834
+ --------
3835
+ >>> idx = pd.Index([1, 2, 3, 4])
3836
+ >>> idx
3837
+ Int64Index([1, 2, 3, 4], dtype='int64')
3838
+
3839
+ >>> idx.contains(2)
3840
+ True
3841
+ >>> idx.contains(6)
3842
+ False
3843
+
3844
+ This is equivalent to:
3845
+
3846
+ >>> 2 in idx
3847
+ True
3848
+ >>> 6 in idx
3849
+ False
3825
3850
"""
3826
3851
3827
- @Appender (_index_shared_docs ['__contains__ ' ] % _index_doc_kwargs )
3852
+ @Appender (_index_shared_docs ['contains ' ] % _index_doc_kwargs )
3828
3853
def __contains__ (self , key ):
3829
3854
hash (key )
3830
3855
try :
3831
3856
return key in self ._engine
3832
3857
except (OverflowError , TypeError , ValueError ):
3833
3858
return False
3834
3859
3835
- _index_shared_docs ['contains' ] = """
3836
- Return a boolean if this key is IN the index.
3837
-
3838
- Parameters
3839
- ----------
3840
- key : object
3841
-
3842
- Returns
3843
- -------
3844
- boolean
3845
- """
3846
-
3847
3860
@Appender (_index_shared_docs ['contains' ] % _index_doc_kwargs )
3848
3861
def contains (self , key ):
3849
3862
hash (key )
0 commit comments