From 9b1780a464bf032472166a73e2db778ed6dc5f3b Mon Sep 17 00:00:00 2001 From: Zhengbo Wang <77875500+luke396@users.noreply.github.com> Date: Sun, 25 Feb 2024 17:09:28 +0800 Subject: [PATCH 1/4] Add DataFrame.isetitem method --- doc/source/reference/frame.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/reference/frame.rst b/doc/source/reference/frame.rst index 31a1c6008bce8..7680c8b434866 100644 --- a/doc/source/reference/frame.rst +++ b/doc/source/reference/frame.rst @@ -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 `. From d511e3f3e46cac4946820f98b3b1f27cd5d1daa6 Mon Sep 17 00:00:00 2001 From: Zhengbo Wang <77875500+luke396@users.noreply.github.com> Date: Sun, 25 Feb 2024 20:31:23 +0800 Subject: [PATCH 2/4] Add See-Also and Examples --- pandas/core/frame.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index df413fda0255a..175aae81e82de 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -4028,6 +4028,20 @@ def isetitem(self, loc, value) -> None: In cases where ``frame.columns`` is unique, this is equivalent to ``frame[frame.columns[i]] = value``. + + See Also + -------- + DataFrame.iloc : Purely integer-location based indexing + for selection by position. + + 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): From 7e527512b3a92ddb9a8402744616bfe0fbf56207 Mon Sep 17 00:00:00 2001 From: Zhengbo Wang <77875500+luke396@users.noreply.github.com> Date: Sun, 25 Feb 2024 23:11:45 +0800 Subject: [PATCH 3/4] Fix orfer --- pandas/core/frame.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 175aae81e82de..bb32afd67bcaa 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -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 @@ -4029,11 +4034,6 @@ def isetitem(self, loc, value) -> None: In cases where ``frame.columns`` is unique, this is equivalent to ``frame[frame.columns[i]] = value``. - See Also - -------- - DataFrame.iloc : Purely integer-location based indexing - for selection by position. - Examples -------- >>> df = pd.DataFrame({"A": [1, 2], "B": [3, 4]}) From 5d00b0c10bc19c4cb3fb24a00fe4e2bac958afbc Mon Sep 17 00:00:00 2001 From: Zhengbo Wang <77875500+luke396@users.noreply.github.com> Date: Tue, 27 Feb 2024 13:41:48 +0800 Subject: [PATCH 4/4] Update pandas/core/frame.py Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- pandas/core/frame.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index bb32afd67bcaa..ad6d411ccb675 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -4020,8 +4020,8 @@ def isetitem(self, loc, value) -> None: See Also -------- - DataFrame.iloc : Purely integer-location based indexing - for selection by position. + DataFrame.iloc : Purely integer-location based indexing for selection by + position. Notes -----