Skip to content

Commit 3b000be

Browse files
fix MultiIndex copy=True case for recent numpy
1 parent 9927903 commit 3b000be

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pandas/core/indexes/multi.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,10 @@ def __array__(self, dtype=None, copy=None) -> np.ndarray:
13961396
raise ValueError(
13971397
"Unable to avoid copy while creating an array as requested."
13981398
)
1399+
if copy is True:
1400+
# explicit np.array call to ensure a copy is made and unique objects
1401+
# are returned, because self.values is cached
1402+
return np.array(self.values, dtype=dtype)
13991403
return self.values
14001404

14011405
def view(self, cls=None) -> Self:

0 commit comments

Comments
 (0)