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

Change pandas to never let objects share _data, create views instead #11855

Closed

Conversation

nickeubank
Copy link
Contributor

Closes Issue #11814

Several pandas operations create objects that share _data objects. In particular, all of the following result in df_news and df sharing the same _data (i.e. df_new._data is df._data returns True).

df = DataFrame({'col1':[0,1,2], 'col2':[2,3,4]})
df_new = DataFrame(df)
df_new1 = df.loc[:,:]
df_new2 = df.iloc[:,:]

Needed for PR #11500

@@ -217,6 +217,7 @@ def __init__(self, data=None, index=None, columns=None, dtype=None,
dtype = self._validate_dtype(dtype)

if isinstance(data, DataFrame):
data = data.iloc[:,:]
data = data._data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to define BlockManager.view() this will do all of the heavy lifting, everything else will flow from there

@jreback jreback added the Internals Related to non-user accessible pandas implementation label Dec 16, 2015
@jreback
Copy link
Contributor

jreback commented Jan 11, 2016

xref #11970

this idea will be incorporated there.

If you want to update before then (as this might take a while), feel free to reopen.

@jreback jreback closed this Jan 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants