Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

phofl
Copy link
Member

@phofl phofl commented May 27, 2022

  • closes #47128 (Replace xxxx with the Github issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

@@ -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)
Copy link
Member Author

@phofl phofl May 27, 2022

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:
Copy link
Member Author

@phofl phofl May 27, 2022

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?

@phofl phofl added this to the 1.4.3 milestone May 27, 2022
phofl and others added 2 commits May 27, 2022
Co-authored-by: Simon Hawkins <simonjayhawkins@gmail.com>
@simonjayhawkins simonjayhawkins added Indexing Regression Copy / view semantics labels May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Copy / view semantics Indexing Regression
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants