Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: fix docstrings for multiple api.types methods #59920

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Timestamp.resolution PR02" \
-i "pandas.Timestamp.tzinfo GL08" \
-i "pandas.Timestamp.year GL08" \
-i "pandas.api.types.is_dict_like PR07,SA01" \
-i "pandas.api.types.is_file_like PR07,SA01" \
-i "pandas.api.types.is_float PR01,SA01" \
-i "pandas.api.types.is_hashable PR01,RT03,SA01" \
-i "pandas.api.types.is_integer PR01,SA01" \
-i "pandas.api.types.is_iterator PR07,SA01" \
-i "pandas.api.types.is_named_tuple PR07,SA01" \
-i "pandas.api.types.is_re PR07,SA01" \
-i "pandas.api.types.is_re_compilable PR07,SA01" \
-i "pandas.api.types.pandas_dtype PR07,RT03,SA01" \
-i "pandas.arrays.ArrowExtensionArray PR07,SA01" \
Expand Down
63 changes: 59 additions & 4 deletions pandas/core/dtypes/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,24 @@ def is_file_like(obj: object) -> bool:

Parameters
----------
obj : The object to check
obj : object
The object to check for file-like properties.
This can be any Python object, and the function will
check if it has attributes typically associated with
file-like objects (e.g., `read`, `write`, `__iter__`).

Returns
-------
bool
Whether `obj` has file-like properties.

See Also
--------
api.types.is_dict_like : Check if the object is dict-like.
api.types.is_hashable : Return True if hash(obj) will succeed, False otherwise.
api.types.is_named_tuple : Check if the object is a named tuple.
api.types.is_iterator : Check if the object is an iterator.

Examples
--------
>>> import io
Expand All @@ -142,13 +153,24 @@ def is_re(obj: object) -> TypeGuard[Pattern]:

Parameters
----------
obj : The object to check
obj : object
The object to check for being a regex pattern. Typically,
this would be an object that you expect to be a compiled
pattern from the `re` module.

Returns
-------
bool
Whether `obj` is a regex pattern.

See Also
--------
api.types.is_float : Return True if given object is float.
api.types.is_iterator : Check if the object is an iterator.
api.types.is_integer : Return True if given object is integer.
api.types.is_re_compilable : Check if the object can be compiled
into a regex pattern instance.

Examples
--------
>>> from pandas.api.types import is_re
Expand Down Expand Up @@ -275,13 +297,22 @@ def is_dict_like(obj: object) -> bool:

Parameters
----------
obj : The object to check
obj : object
The object to check. This can be any Python object,
and the function will determine whether it
behaves like a dictionary.

Returns
-------
bool
Whether `obj` has dict-like properties.

See Also
--------
api.types.is_list_like : Check if the object is list-like.
api.types.is_file_like : Check if the object is a file-like.
api.types.is_named_tuple : Check if the object is a named tuple.

Examples
--------
>>> from pandas.api.types import is_dict_like
Expand All @@ -308,13 +339,22 @@ def is_named_tuple(obj: object) -> bool:

Parameters
----------
obj : The object to check
obj : object
The object that will be checked to determine
whether it is a named tuple.

Returns
-------
bool
Whether `obj` is a named tuple.

See Also
--------
api.types.is_dict_like: Check if the object is dict-like.
api.types.is_hashable: Return True if hash(obj)
will succeed, False otherwise.
api.types.is_categorical_dtype : Check if the dtype is categorical.

Examples
--------
>>> from collections import namedtuple
Expand All @@ -340,9 +380,24 @@ def is_hashable(obj: object) -> TypeGuard[Hashable]:
Distinguish between these and other types by trying the call to hash() and
seeing if they raise TypeError.

Parameters
----------
obj : object
The object to check for hashability. Any Python object can be passed here.

Returns
-------
bool
True if object can be hashed (i.e., does not raise TypeError when
passed to hash()), and False otherwise (e.g., if object is mutable
like a list or dictionary).

See Also
--------
api.types.is_float : Return True if given object is float.
api.types.is_iterator : Check if the object is an iterator.
api.types.is_list_like : Check if the object is list-like.
api.types.is_dict_like : Check if the object is dict-like.

Examples
--------
Expand Down
Loading