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

BUG: overriden methods of subclasses of Styler are not called during … #52865

Closed
Changes from all commits
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
11 changes: 5 additions & 6 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,8 @@ def _update_ctx_header(self, attrs: DataFrame, axis: AxisInt) -> None:
else:
self.ctx_columns[(j, i)].extend(css_list)

def _copy(self, deepcopy: bool = False) -> Styler:

def _copy(cls, self, deepcopy: bool = False) -> Styler:
"""
Copies a Styler, allowing for deepcopy or shallow copy

Expand All @@ -1579,9 +1580,7 @@ def _copy(self, deepcopy: bool = False) -> Styler:

"""
# GH 40675
styler = Styler(
self.data, # populates attributes 'data', 'columns', 'index' as shallow
)
styler = cls(self.data)
shallow = [ # simple string or boolean immutables
"hide_index_",
"hide_columns_",
Expand Down Expand Up @@ -1624,10 +1623,10 @@ def _copy(self, deepcopy: bool = False) -> Styler:
return styler

def __copy__(self) -> Styler:
return self._copy(deepcopy=False)
return self._copy(self.__class__, deepcopy=False)

def __deepcopy__(self, memo) -> Styler:
return self._copy(deepcopy=True)
return self._copy(self.__class__, deepcopy=True)

def clear(self) -> None:
"""
Expand Down