Skip to content

Commit 34f546f

Browse files
authored
DOC: fix docstrings for multiple api.types methods (#59920)
fix docstrings for api.types
1 parent d538a1c commit 34f546f

File tree

2 files changed

+59
-9
lines changed

2 files changed

+59
-9
lines changed

ci/code_checks.sh

-5
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
107107
-i "pandas.Timestamp.resolution PR02" \
108108
-i "pandas.Timestamp.tzinfo GL08" \
109109
-i "pandas.Timestamp.year GL08" \
110-
-i "pandas.api.types.is_dict_like PR07,SA01" \
111-
-i "pandas.api.types.is_file_like PR07,SA01" \
112110
-i "pandas.api.types.is_float PR01,SA01" \
113-
-i "pandas.api.types.is_hashable PR01,RT03,SA01" \
114111
-i "pandas.api.types.is_integer PR01,SA01" \
115112
-i "pandas.api.types.is_iterator PR07,SA01" \
116-
-i "pandas.api.types.is_named_tuple PR07,SA01" \
117-
-i "pandas.api.types.is_re PR07,SA01" \
118113
-i "pandas.api.types.is_re_compilable PR07,SA01" \
119114
-i "pandas.api.types.pandas_dtype PR07,RT03,SA01" \
120115
-i "pandas.arrays.ArrowExtensionArray PR07,SA01" \

pandas/core/dtypes/inference.py

+59-4
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,24 @@ def is_file_like(obj: object) -> bool:
113113
114114
Parameters
115115
----------
116-
obj : The object to check
116+
obj : object
117+
The object to check for file-like properties.
118+
This can be any Python object, and the function will
119+
check if it has attributes typically associated with
120+
file-like objects (e.g., `read`, `write`, `__iter__`).
117121
118122
Returns
119123
-------
120124
bool
121125
Whether `obj` has file-like properties.
122126
127+
See Also
128+
--------
129+
api.types.is_dict_like : Check if the object is dict-like.
130+
api.types.is_hashable : Return True if hash(obj) will succeed, False otherwise.
131+
api.types.is_named_tuple : Check if the object is a named tuple.
132+
api.types.is_iterator : Check if the object is an iterator.
133+
123134
Examples
124135
--------
125136
>>> import io
@@ -142,13 +153,24 @@ def is_re(obj: object) -> TypeGuard[Pattern]:
142153
143154
Parameters
144155
----------
145-
obj : The object to check
156+
obj : object
157+
The object to check for being a regex pattern. Typically,
158+
this would be an object that you expect to be a compiled
159+
pattern from the `re` module.
146160
147161
Returns
148162
-------
149163
bool
150164
Whether `obj` is a regex pattern.
151165
166+
See Also
167+
--------
168+
api.types.is_float : Return True if given object is float.
169+
api.types.is_iterator : Check if the object is an iterator.
170+
api.types.is_integer : Return True if given object is integer.
171+
api.types.is_re_compilable : Check if the object can be compiled
172+
into a regex pattern instance.
173+
152174
Examples
153175
--------
154176
>>> from pandas.api.types import is_re
@@ -275,13 +297,22 @@ def is_dict_like(obj: object) -> bool:
275297
276298
Parameters
277299
----------
278-
obj : The object to check
300+
obj : object
301+
The object to check. This can be any Python object,
302+
and the function will determine whether it
303+
behaves like a dictionary.
279304
280305
Returns
281306
-------
282307
bool
283308
Whether `obj` has dict-like properties.
284309
310+
See Also
311+
--------
312+
api.types.is_list_like : Check if the object is list-like.
313+
api.types.is_file_like : Check if the object is a file-like.
314+
api.types.is_named_tuple : Check if the object is a named tuple.
315+
285316
Examples
286317
--------
287318
>>> from pandas.api.types import is_dict_like
@@ -308,13 +339,22 @@ def is_named_tuple(obj: object) -> bool:
308339
309340
Parameters
310341
----------
311-
obj : The object to check
342+
obj : object
343+
The object that will be checked to determine
344+
whether it is a named tuple.
312345
313346
Returns
314347
-------
315348
bool
316349
Whether `obj` is a named tuple.
317350
351+
See Also
352+
--------
353+
api.types.is_dict_like: Check if the object is dict-like.
354+
api.types.is_hashable: Return True if hash(obj)
355+
will succeed, False otherwise.
356+
api.types.is_categorical_dtype : Check if the dtype is categorical.
357+
318358
Examples
319359
--------
320360
>>> from collections import namedtuple
@@ -340,9 +380,24 @@ def is_hashable(obj: object) -> TypeGuard[Hashable]:
340380
Distinguish between these and other types by trying the call to hash() and
341381
seeing if they raise TypeError.
342382
383+
Parameters
384+
----------
385+
obj : object
386+
The object to check for hashability. Any Python object can be passed here.
387+
343388
Returns
344389
-------
345390
bool
391+
True if object can be hashed (i.e., does not raise TypeError when
392+
passed to hash()), and False otherwise (e.g., if object is mutable
393+
like a list or dictionary).
394+
395+
See Also
396+
--------
397+
api.types.is_float : Return True if given object is float.
398+
api.types.is_iterator : Check if the object is an iterator.
399+
api.types.is_list_like : Check if the object is list-like.
400+
api.types.is_dict_like : Check if the object is dict-like.
346401
347402
Examples
348403
--------

0 commit comments

Comments
 (0)