File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 5252 "is_categorical_dtype" , None )
5353have_pandas_categorical_dtype = _pandas_is_categorical_dtype is not None
5454
55+ # The handling of the `copy` keyword has been changed since numpy>=2.
56+ # https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword
57+ # If numpy<2 support is dropped, this try-clause can be removed.
58+ try :
59+ np .array ([1 ]).__array__ (copy = None )
60+ copy_if_needed = None
61+ except TypeError :
62+ copy_if_needed = False
63+
5564
5665# Passes through Series and DataFrames, call np.asarray() on everything else
57- def asarray_or_pandas (a , copy = False , dtype = None , subok = False ):
66+ def asarray_or_pandas (a , copy = copy_if_needed , dtype = None , subok = False ):
5867 if have_pandas :
5968 if isinstance (a , (pandas .Series , pandas .DataFrame )):
6069 # The .name attribute on Series is discarded when passing through
You can’t perform that action at this time.
0 commit comments