[BUG] Pandas 2.0 styler.render not existing anymore
jultou-raa opened this issue · comments
Julien T. commented
Describe the bug
This bug concern core/serialization/dataframe/html.py file and may be other when using pandas 2.
starting at line 43
serialize(self, **kwargs) -> str:
"""Serialize pandas.DataFrame instance into HTML format."""
try:
if isinstance(self.value, pd.DataFrame):
df_styler = self.value.style
else:
df_styler = self.value
# Using deprecated pandas method so hiding the warning
with warnings.catch_warnings():
warnings.simplefilter(action='ignore', category=FutureWarning)
# Set precision is deprecated since pandas 1.3.0
if parse_version(pd.__version__) < parse_version('1.3.0'):
df_styler.set_precision(2)
else:
df_styler.format(precision=2)
table_css_props = [
('text-align', 'left'), # Align everything to the left
('white-space', 'pre-wrap') # Define how to handle white space characters (like \n)
]
df_styler.set_table_styles([dict(selector='table,thead,tbody,th,td', props=table_css_props)])
return df_styler.render()
The render method does not exist anymore and is deprecated since pandas 1.4 and must be replaced by to_html method.