Skip to content

Commit

Permalink
BUG: overriden methods of subclasses of Styler are not called during …
Browse files Browse the repository at this point in the history
…rendering #52728

BUG: overriden methods of subclasses of Styler are not called during rendering #52728
  • Loading branch information
YifanChao committed Apr 23, 2023
1 parent 34a1048 commit 8df280a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ 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 +1579,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 +1622,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

0 comments on commit 8df280a

Please sign in to comment.