File tree 4 files changed +12
-6
lines changed
4 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -355,7 +355,7 @@ ExtensionArray
355
355
Styler
356
356
^^^^^^
357
357
- Minor bug in :class: `.Styler ` where the ``uuid `` at initialization maintained a floating underscore (:issue: `43037 `)
358
- -
358
+ - Bug in :meth: ` .Styler.to_html ` where the `` Styler `` object was updated if the `` to_html `` method was called with some args ( :issue: ` 43034 `)
359
359
360
360
Other
361
361
^^^^^
Original file line number Diff line number Diff line change @@ -900,19 +900,21 @@ def to_html(
900
900
--------
901
901
DataFrame.to_html: Write a DataFrame to a file, buffer or string in HTML format.
902
902
"""
903
+ obj = self ._copy (deepcopy = True ) # manipulate table_styles on obj, not self
904
+
903
905
if table_uuid :
904
- self .set_uuid (table_uuid )
906
+ obj .set_uuid (table_uuid )
905
907
906
908
if table_attributes :
907
- self .set_table_attributes (table_attributes )
909
+ obj .set_table_attributes (table_attributes )
908
910
909
911
if sparse_index is None :
910
912
sparse_index = get_option ("styler.sparse.index" )
911
913
if sparse_columns is None :
912
914
sparse_columns = get_option ("styler.sparse.columns" )
913
915
914
916
# Build HTML string..
915
- html = self ._render_html (
917
+ html = obj ._render_html (
916
918
sparse_index = sparse_index ,
917
919
sparse_columns = sparse_columns ,
918
920
exclude_styles = exclude_styles ,
@@ -1088,6 +1090,10 @@ def _copy(self, deepcopy: bool = False) -> Styler:
1088
1090
"caption" ,
1089
1091
"uuid" ,
1090
1092
"uuid_len" ,
1093
+ "template_latex" , # also copy templates if these have been customised
1094
+ "template_html_style" ,
1095
+ "template_html_table" ,
1096
+ "template_html" ,
1091
1097
]
1092
1098
deep = [ # nested lists or dicts
1093
1099
"_display_funcs" ,
Original file line number Diff line number Diff line change @@ -260,7 +260,7 @@ def test_from_custom_template_style(tmpdir):
260
260
assert result .env is not Styler .env
261
261
assert result .template_html_style is not Styler .template_html_style
262
262
styler = result (DataFrame ({"A" : [1 , 2 ]}))
263
- assert '<link rel="stylesheet" href="mystyle.css">\n \n <style' in styler .render ()
263
+ assert '<link rel="stylesheet" href="mystyle.css">\n \n <style' in styler .to_html ()
264
264
265
265
266
266
def test_caption_as_sequence (styler ):
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ def mi_styler(mi_df):
42
42
def mi_styler_comp (mi_styler ):
43
43
# comprehensively add features to mi_styler
44
44
mi_styler .uuid_len = 5
45
- mi_styler .uuid = "abcde_ "
45
+ mi_styler .uuid = "abcde "
46
46
mi_styler .set_caption ("capt" )
47
47
mi_styler .set_table_styles ([{"selector" : "a" , "props" : "a:v;" }])
48
48
mi_styler .hide_columns ()
You can’t perform that action at this time.
0 commit comments