You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_____________________________________________________________ [doctest] pandas.io.formats.style.Styler.to_latex _____________________________________________________________
530 should be replaced by a LaTeX
531 ``(<command>, <options>)`` approach. Each cell will be styled individually
532 using nested LaTeX commands with their accompanied options.
533
534 For example the following code will highlight and bold a cell in HTML-CSS:
535
536 >>> df = pd.DataFrame([[1,2], [3,4]])
537 >>> s = df.style.highlight_max(axis=None,
538 ... props='background-color:red; font-weight:bold;')
539 >>> s.render()
Expected nothing
Got:
'<style type="text/css">\n#T_d86c0_row1_col1 {\n background-color: red;\n font-weight: bold;\n}\n</style>\n<table id="T_d86c0_">\n <thead>\n <tr>\n <th class="blank level0" > </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="T_d86c0_level0_row0" class="row_heading level0 row0" >0</th>\n <td id="T_d86c0_row0_col0" class="data row0 col0" >1</td>\n <td id="T_d86c0_row0_col1" class="data row0 col1" >2</td>\n </tr>\n <tr>\n <th id="T_d86c0_level0_row1" class="row_heading level0 row1" >1</th>\n <td id="T_d86c0_row1_col0" class="data row1 col0" >3</td>\n <td id="T_d86c0_row1_col1" class="data row1 col1" >4</td>\n </tr>\n </tbody>\n</table>\n'
/home/mgarcia/src/pandas/pandas/io/formats/style.py:539: DocTestFailure
Detailed instructions
Python allows to have example code in the documentation, like in:
defadd(num1, num2):
""" Computes the sum of the two numbers. Examples -------- >>> add(2, 2) 4 """returnnum1+num2
In pandas, we use this to document most elements. And there are tools, like pytest,
that can run the examples, and make sure everything is correct.
For historical reasons, we have many examples where the code fails to run, or the
actual output is different from the expected output. For example, check the next
incorrect examples:
defadd(num1, num2):
""" Computes the sum of the two numbers. Examples -------- >>> add(2, 2) 5 >>> add(2, 2 4 >>> add(2, number) 4 ... """returnnum1+num2
All them will fail for different reasons. To test the docstring of an object,
the next command can be run:
Where pandas/core/frame.py is the file where the docstring is defined, and pandas.core.frame.DataFrame.info is the object. A whole file can also be tested
by removing the :: and the object from the command above.
In general, the errors in the examples can be fixed with things like:
Fixing a typo (a missing comma, an mispelled variable name...)
Adding an object that hasn't been defined (like, if df is used, but
no sample dataset df has been first defined)
Fixing the expected output, when it's wrong
In exceptional cases, examples shouldn't run, since they can't work.
For example, a function that connects to a private webservice. In
such cases, we can add # doctest: +SKIP at the end of the lines
that should not run
To be able to properly fix an example for the first time, the next steps
are needed:
Run the doctests for the object of interest (the one in this issue),
and make sure the examples are still broken in the master branch of
pandas
Fix the file locally, and run the doctests again, to make sure the
fix is working as expected
Optionally have a look and make sure that the code in the examples
follow PEP-8, and fix the style if it doesn't
Commit your changes, push your branch to a fork, and open a pull
request. Make sure you edit the line Closes #XXXX with the issue
number you are addressing, so the issue is automatically closed,
when the pull request is merged
Make sure the continuous integration of your pull request finishes
in green. If it doesn't, check if the problem is in your changes
(sometimes things break in master for technical problems, and in
that case you just need to wait for a core developer to fix the
problem)
Address any comment from the reviewers (just make changes locally,
commit, and push to your branch, no need to open new pull requests)
The text was updated successfully, but these errors were encountered:
i would recommend the fix for this is to skip the test. The point of styler examples is to display the rendered output or as a comparison, not the textual output used by the render (e.g. browser or latex reader). Adding textual output will pollute the docstring.
tl;dr
Fix the next doctest error:
Detailed instructions
Python allows to have example code in the documentation, like in:
In pandas, we use this to document most elements. And there are tools, like pytest,
that can run the examples, and make sure everything is correct.
For historical reasons, we have many examples where the code fails to run, or the
actual output is different from the expected output. For example, check the next
incorrect examples:
All them will fail for different reasons. To test the docstring of an object,
the next command can be run:
Where
pandas/core/frame.py
is the file where the docstring is defined, andpandas.core.frame.DataFrame.info
is the object. A whole file can also be testedby removing the
::
and the object from the command above.In general, the errors in the examples can be fixed with things like:
df
is used, butno sample dataset
df
has been first defined)For example, a function that connects to a private webservice. In
such cases, we can add
# doctest: +SKIP
at the end of the linesthat should not run
To be able to properly fix an example for the first time, the next steps
are needed:
simplified instructions in this page,
and more detailed information in pandas official contributing page.
and make sure the examples are still broken in the
master
branch ofpandas
fix is working as expected
follow PEP-8, and fix the style if it doesn't
request. Make sure you edit the line
Closes #XXXX
with the issuenumber you are addressing, so the issue is automatically closed,
when the pull request is merged
in green. If it doesn't, check if the problem is in your changes
(sometimes things break in master for technical problems, and in
that case you just need to wait for a core developer to fix the
problem)
commit, and push to your branch, no need to open new pull requests)
The text was updated successfully, but these errors were encountered: