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: Add DataFrame.isetitem method #57614

Merged
merged 4 commits into from
Feb 27, 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
1 change: 1 addition & 0 deletions doc/source/reference/frame.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Indexing, iteration
DataFrame.where
DataFrame.mask
DataFrame.query
DataFrame.isetitem

For more information on ``.at``, ``.iat``, ``.loc``, and
``.iloc``, see the :ref:`indexing documentation <indexing>`.
Expand Down
14 changes: 14 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4018,6 +4018,11 @@ def isetitem(self, loc, value) -> None:
value : scalar or arraylike
Value(s) for the column.

See Also
--------
DataFrame.iloc : Purely integer-location based indexing for selection by
position.

Notes
-----
``frame.isetitem(loc, value)`` is an in-place method as it will
Expand All @@ -4028,6 +4033,15 @@ def isetitem(self, loc, value) -> None:

In cases where ``frame.columns`` is unique, this is equivalent to
``frame[frame.columns[i]] = value``.

Examples
--------
>>> df = pd.DataFrame({"A": [1, 2], "B": [3, 4]})
>>> df.isetitem(1, [5, 6])
>>> df
A B
0 1 5
1 2 6
"""
if isinstance(value, DataFrame):
if is_integer(loc):
Expand Down