From 3474043a4a8511523e71479e8c3dee4d8b31b6e7 Mon Sep 17 00:00:00 2001 From: Manju080 Date: Thu, 6 Mar 2025 17:16:58 +0000 Subject: [PATCH 1/5] DOC: Update warning in Index.values docstring to clarify index modification issues (#60954) --- pandas/core/indexes/base.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 852049804a4f5..3342e67f111ca 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -4912,6 +4912,10 @@ def values(self) -> ArrayLike: :meth:`Index.to_numpy`, depending on whether you need a reference to the underlying data or a NumPy array. + Modifying 'Index.values' directly is not supported and can lead to memory + corruption or segmentation faults. This is because 'Index.values' provides + a direct reference to internal NumPy data. + Returns ------- array: numpy.ndarray or ExtensionArray From d070b066ffd6595816bee39eb5acffe147829067 Mon Sep 17 00:00:00 2001 From: Manju080 Date: Fri, 7 Mar 2025 18:34:26 +0000 Subject: [PATCH 2/5] DOC: Update warning in Index.values docstring to clarify index modification issues (#60954) with changes --- pandas/core/indexes/base.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 3342e67f111ca..3ad788507dab8 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -4912,9 +4912,8 @@ def values(self) -> ArrayLike: :meth:`Index.to_numpy`, depending on whether you need a reference to the underlying data or a NumPy array. - Modifying 'Index.values' directly is not supported and can lead to memory - corruption or segmentation faults. This is because 'Index.values' provides - a direct reference to internal NumPy data. + .. versionchanged:: 3.0.0 + The returned array is read-only. Returns ------- From b00ba12da01c6f96541b6400f112fea9fb673e84 Mon Sep 17 00:00:00 2001 From: Manjunath L <84699147+Manju080@users.noreply.github.com> Date: Sat, 8 Mar 2025 10:19:51 +0530 Subject: [PATCH 3/5] Update pandas/core/indexes/base.py Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- pandas/core/indexes/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 3ad788507dab8..fe89a524735ce 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -4912,8 +4912,9 @@ def values(self) -> ArrayLike: :meth:`Index.to_numpy`, depending on whether you need a reference to the underlying data or a NumPy array. - .. versionchanged:: 3.0.0 - The returned array is read-only. + .. versionchanged:: 3.0.0 + + The returned array is read-only. Returns ------- From 390c8be44e5320bd4d761fde8c98fcd099fd05ff Mon Sep 17 00:00:00 2001 From: Manju080 Date: Mon, 10 Mar 2025 17:10:58 +0000 Subject: [PATCH 4/5] DOC : Fixing the whitespace which was causing error --- pandas/core/indexes/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index fe89a524735ce..2993837e41edb 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -4912,9 +4912,9 @@ def values(self) -> ArrayLike: :meth:`Index.to_numpy`, depending on whether you need a reference to the underlying data or a NumPy array. - .. versionchanged:: 3.0.0 - - The returned array is read-only. + .. versionchanged:: 3.0.0 + + The returned array is read-only. Returns ------- From e58f383ad20a1501b200301262090e1e43c7b0ae Mon Sep 17 00:00:00 2001 From: Manju080 Date: Tue, 11 Mar 2025 14:43:27 +0000 Subject: [PATCH 5/5] Fixed docstring validation and formatting issues --- pandas/core/indexes/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 2993837e41edb..855425c3cb636 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -4913,7 +4913,7 @@ def values(self) -> ArrayLike: a reference to the underlying data or a NumPy array. .. versionchanged:: 3.0.0 - + The returned array is read-only. Returns