Skip to content

fixed doctest in styler.to_latex #42711

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

Closed
wants to merge 3 commits into from
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
13 changes: 12 additions & 1 deletion pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,18 @@ def to_latex(
>>> df = pd.DataFrame([[1,2], [3,4]])
>>> s = df.style.highlight_max(axis=None,
... props='background-color:red; font-weight:bold;')
>>> s.render()
>>> s.render() #doctest: +ELLIPSIS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to leave two spaces before the # and one after.

'<style type="text/css">\n#..._row1_col1 {\n background-color: red;\n
font-weight: bold;\n}\n</style>\n<table id="...">\n <thead>\n <tr>\n
<th class="blank level0" >&nbsp;</th>\n <th class="col_heading
level0 col0" >0</th>\n <th class="col_heading level0 col1" >1</th>\n
</tr>\n </thead>\n <tbody>\n <tr>\n <th id="..._level0_row0"
class="row_heading level0 row0" >0</th>\n <td id="..._row0_col0"
class="data row0 col0" >1</td>\n <td id="..._row0_col1" class="data
row0 col1" >2</td>\n </tr>\n <tr>\n <th id="..._level0_row1"
class="row_heading level0 row1" >1</th>\n <td id="..._row1_col0"
class="data row1 col0" >3</td>\n <td id="..._row1_col1"
class="data row1 col1" >4</td>\n </tr>\n </tbody>\n</table>\n'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not very useful to have something so big. Maybe add the <style type="text/css">...</style><table ...</table> or something like this helps understand what this is returning in a more concise way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah aha, that 100% makes sense. Will be creating a new pull request since I messed up something in my current repository


The equivalent using LaTeX only commands is the following:

Expand Down