Skip to content

DOC: Convert docstring to numpydoc. #54617

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

Merged
merged 1 commit into from
Aug 18, 2023
Merged
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
27 changes: 17 additions & 10 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,17 +531,24 @@ def convert_to_list_like(
def temp_setattr(
obj, attr: str, value, condition: bool = True
) -> Generator[None, None, None]:
"""Temporarily set attribute on an object.

Args:
obj: Object whose attribute will be modified.
attr: Attribute to modify.
value: Value to temporarily set attribute to.
condition: Whether to set the attribute. Provided in order to not have to
conditionally use this context manager.
"""
Temporarily set attribute on an object.

Yields:
obj with modified attribute.
Parameters
----------
obj : object
Object whose attribute will be modified.
attr : str
Attribute to modify.
value : Any
Value to temporarily set attribute to.
condition : bool, default True
Whether to set the attribute. Provided in order to not have to
conditionally use this context manager.

Yields
------
object : obj with modified attribute.
"""
if condition:
old_value = getattr(obj, attr)
Expand Down