pandas-dev / pandas Public
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REGR: setitem writing into RangeIndex instead of creating a copy #47143
base: main
Are you sure you want to change the base?
Conversation
@@ -531,7 +531,7 @@ def sanitize_array( | |||
dtype = dtype.numpy_dtype | |||
|
|||
# extract ndarray or ExtensionArray, ensure we have no PandasArray | |||
data = extract_array(data, extract_numpy=True) | |||
data = extract_array(data, extract_numpy=True, extract_range=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the correct place to handle RangeIndexes, but this leaves us in the same position with other array types, like dask arrays, hence the copy below
@@ -611,6 +611,8 @@ def sanitize_array( | |||
if hasattr(data, "__array__"): | |||
# e.g. dask array GH#38645 | |||
data = np.asarray(data) | |||
if copy: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an efficient way to check if asarray already made a copy?
Co-authored-by: Simon Hawkins <simonjayhawkins@gmail.com>
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.