-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF: move reshaping of array for setitem from DataFrame into BlockManager internals #39722
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 all commits
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 |
---|---|---|
|
@@ -1013,6 +1013,9 @@ def value_getitem(placement): | |
return value | ||
|
||
else: | ||
if value.ndim == 2: | ||
value = value.T | ||
|
||
if value.ndim == self.ndim - 1: | ||
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. this can become an elif 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. indeed, will also include in a next PR 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. Actually, it needs to be an |
||
value = safe_reshape(value, (1,) + value.shape) | ||
|
||
|
@@ -1135,6 +1138,9 @@ def insert(self, loc: int, item: Hashable, value, allow_duplicates: bool = False | |
# insert to the axis; this could possibly raise a TypeError | ||
new_axis = self.items.insert(loc, item) | ||
|
||
if value.ndim == 2: | ||
value = value.T | ||
|
||
if value.ndim == self.ndim - 1 and not is_extension_array_dtype(value.dtype): | ||
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. elif |
||
# TODO(EA2D): special case not needed with 2D EAs | ||
value = safe_reshape(value, (1,) + value.shape) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -350,9 +350,9 @@ def test_fillna_fill_other(self, data_missing): | |
|
||
|
||
class TestReshaping(BaseNumPyTests, base.BaseReshapingTests): | ||
@skip_nested | ||
@pytest.mark.skip(reason="Incorrect expected.") | ||
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. why did this change? 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. I don't fully understand how testing with the PandasArrays works, but, within the 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. this turns out to be a PITA in a bunch of places. could just monkeypatch extract_array to extract PandasArray too |
||
def test_merge(self, data, na_value): | ||
# Fails creating expected | ||
# Fails creating expected (key column becomes a PandasDtype because) | ||
super().test_merge(data, na_value) | ||
|
||
@skip_nested | ||
|
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 removed all the usages of maybe_atleast_2d, so can remove the function
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.
Indeed, will remove that in one of my next PRs