-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
BUG: 2D ndarray of dtype 'object' is always copied upon construction #39272
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
Changes from 10 commits
ff2f271
90097ae
570dbe1
64abe4c
cb59f2a
672f9c0
b6b248a
b09a763
59597f3
f632526
ac71b7d
9e00908
ba0d122
f951246
99aca53
e9d4166
e91fb3a
96dd1b9
dc2ae20
aa45230
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2080,6 +2080,14 @@ def test_constructor_series_copy(self, float_frame): | |
|
||
assert not (series["A"] == 5).all() | ||
|
||
def test_object_array_does_not_copy(self): | ||
a = np.array(["a", "b"], dtype="object") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so if we have any columns that are inferred as datetimelike, we get copies of everything, i.e. dont retain any of the original array? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If one of the columns is inferred as datetimelike, each column is created as its own block. From my understanding, upon consolidation, these blocks get copied to a(nother) contiguous location. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add the issue number as a comment |
||
b = np.array([["a", "b"], ["c", "d"]], dtype="object") | ||
df = DataFrame(a) | ||
assert np.shares_memory(df.values, a) | ||
df2 = DataFrame(b) | ||
assert np.shares_memory(df2.values, b) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. assert the frames are equal as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you mean assert the numpy arrays equal? They're not equal, but they do share memory:
(note also I've split the test into two) |
||
def test_constructor_with_nas(self): | ||
# GH 5016 | ||
# na's in indices | ||
|
Uh oh!
There was an error while loading. Please reload this page.