Skip to content

Commit 33a4d34

Browse files
authored
Update datetimelike.py
1 parent ae48396 commit 33a4d34

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

pandas/core/indexes/datetimelike.py

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,38 @@ def equals(self, other: Any) -> bool:
199199

200200
def __contains__(self, key: Any) -> bool:
201201
"""
202-
Return True if the key is in the Index.
202+
Return a boolean indicating whether the provided key is in the index.
203+
204+
Parameters
205+
----------
206+
key : label
207+
The key to check if it is present in the index.
208+
209+
Returns
210+
-------
211+
bool
212+
Whether the key search is in the index.
213+
214+
Raises
215+
------
216+
TypeError
217+
If the key is not hashable.
218+
219+
See Also
220+
--------
221+
Index.isin : Returns an ndarray of boolean dtype indicating whether the
222+
list-like key is in the index.
223+
224+
Examples
225+
--------
226+
>>> idx = pd.Index([1, 2, 3, 4])
227+
>>> idx
228+
Index([1, 2, 3, 4], dtype='int64')
229+
230+
>>> 2 in idx
231+
True
232+
>>> 6 in idx
233+
False
203234
"""
204235
hash(key)
205236
try:
@@ -245,7 +276,16 @@ def _format_attrs(self):
245276

246277
def _summary(self, name=None) -> str:
247278
"""
248-
Return a summary of the Index.
279+
Return a summarized representation.
280+
281+
Parameters
282+
----------
283+
name : str
284+
name to use in the summary representation
285+
286+
Returns
287+
-------
288+
String with a summarized representation of the index
249289
"""
250290
result = super()._summary(name=name)
251291
if self.freq:

0 commit comments

Comments
 (0)