File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
pandas/tests/extension/json Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 2525 TYPE_CHECKING ,
2626 Any ,
2727)
28+ import warnings
2829
2930import numpy as np
3031
32+ from pandas .util ._exceptions import find_stack_level
33+
3134from pandas .core .dtypes .cast import construct_1d_object_array_from_listlike
3235from pandas .core .dtypes .common import (
3336 is_bool_dtype ,
@@ -148,8 +151,14 @@ def __ne__(self, other):
148151
149152 def __array__ (self , dtype = None , copy = None ):
150153 if copy is False :
151- raise ValueError (
152- "Unable to avoid copy while creating an array as requested."
154+ warnings .warn (
155+ "Starting on NumPy 2.0, the behavior of the 'copy' keyword has changed "
156+ "and passing 'copy=False' raises an error when a zero-copy NumPy array "
157+ "is not possible, Pandas will follow this behavior starting with "
158+ "version 3.0. This conversion to NumPy requires a copy, but "
159+ "'copy=False' was passed. Consider using 'np.asarray(..)' instead." ,
160+ FutureWarning ,
161+ stacklevel = find_stack_level (),
153162 )
154163
155164 if dtype is None :
You can’t perform that action at this time.
0 commit comments