Skip to content

Commit 5489d51

Browse files
committed
Make Index.values read-only
1 parent 3e88e17 commit 5489d51

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pandas/core/indexes/base.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3849,7 +3849,9 @@ def values(self) -> np.ndarray:
38493849
Index.array : Reference to the underlying data.
38503850
Index.to_numpy : A NumPy array representing the underlying data.
38513851
"""
3852-
return self._data.view(np.ndarray)
3852+
vals = self._data.view(np.ndarray)
3853+
vals.setflags(write=False)
3854+
return vals
38533855

38543856
@cache_readonly
38553857
@doc(IndexOpsMixin.array)

0 commit comments

Comments
 (0)