8000 Pass method in __finalize__ by TomAugspurger · Pull Request #33273 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

Pass method in __finalize__ #33273

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

Merged
merged 6 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more
8000
  • Loading branch information
TomAugspurger committed Apr 6, 2020
commit d6188c1e403bf72cf9ac8054e99d4708a0996d06
16 changes: 8 additions & 8 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,7 @@ def __invert__(self):
# inv fails with 0 len
return self

new_data = self._data.apply(operator.invert)
new_data = self._mgr.apply(operator.invert)
result = self._constructor(new_data).__finalize__(self, method="__invert__")
return result

Expand Down Expand Up @@ -3573,7 +3573,7 @@ def _slice(self: FrameOrSeries, slobj: slice, axis=0) -> FrameOrSeries:
"""
assert isinstance(slobj, slice), type(slobj)
axis = self._get_block_manager_axis(axis)
result = self._constructor(self._data.get_slice(slobj, axis=axis))
result = self._constructor(self._mgr.get_slice(slobj, axis=axis))
result = result.__finalize__(self, method="_slice")

# this could be a view
Expand Down Expand Up @@ -5308,12 +5308,12 @@ def _check_inplace_setting(self, value) -> bool_t:
return True

def _get_numeric_data(self):
return self._constructor(self._data.get_numeric_data()).__finalize__(
return self._constructor(self._mgr.get_numeric_data()).__finalize__(
self, method="_get_numeric_data"
)

def _get_bool_data(self):
return self._constructor(self._data.get_bool_data()).__finalize__(
return self._constructor(self._mgr.get_bool_data()).__finalize__(
self, method="_get_bool_data"
)

Expand Down Expand Up @@ -5442,8 +5442,8 @@ def _to_dict_of_blocks(self, copy: bool_t = True):
Internal ONLY
"""
return {
k: self._constructor(v).__finalize__(self, mehtod="_to_dict_of_blocks")
for k, v, in self._data.to_dict(copy=copy).items()
k: self._constructor(v).__finalize__(self, method="_to_dict_of_blocks")
for k, v, in self._mgr.to_dict(copy=copy).items()
}

def astype(
Expand Down Expand Up @@ -5581,8 +5581,8 @@ def astype(

else:
# else, only a single dtype is given
new_data = self._data.astype(dtype=dtype, copy=copy, errors=errors)
return self._constructor(new_data).__finalize__(self, method="_astype")
new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors,)
return self._constructor(new_data).__finalize__(self, method="astype")

# GH 19920: retain column metadata after concat
result = pd.concat(results, axis=1, copy=False)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ def _get_values_tuple(self, key):

def _get_values(self, indexer):
try:
return self._constructor(self._data.get_slice(indexer)).__finalize__(
return self._constructor(self._mgr.get_slice(indexer)).__finalize__(
self, method="_get_values"
)
except ValueError:
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0