Skip to content

Styler render creates extra indent which when exported to markdown becomes a code block #15651

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
danfrankj opened this issue Mar 11, 2017 · 2 comments
Labels
IO HTML read_html, to_html, Styler.apply, Styler.applymap

Comments

@danfrankj
Copy link
Contributor

Code Sample, a copy-pastable example if possible

# Your code here
In [12]: df
Out[12]:
   A       B       C
0  1  0.5021 -1.8989
1  0 -0.0123  0.4893
2  0 -1.0470 -0.9169

In [13]: print(df.style.set_caption('example').render())

        <style  type="text/css" >


        </style>

        <table id="T_abffa708_05f4_11e7_920b_acbc329287af" None>

            <caption>example</caption>


        <thead>

            <tr>


                <th class="blank level0" >




                <th class="col_heading level0 col0" colspan=1>
                  A

Problem description

Although the above output renders fine in an ipython notebook, when that notebook is then exported to markdown, the indent is interpreted as a code block so the output HTML renders as a code block

Expected Output

Same thing, just no indent.

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.5.1.final.0 python-bits: 64 OS: Darwin OS-release: 16.0.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8

pandas: 0.19.2
nose: None
pip: 8.1.2
setuptools: 34.1.1
Cython: None
numpy: 1.12.0
scipy: 0.18.1
statsmodels: 0.6.1
xarray: None
IPython: 5.2.1
sphinx: None
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 2.0.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.9999999
httplib2: None
apiclient: None
sqlalchemy: 1.1.5
pymysql: None
psycopg2: None
jinja2: 2.9.5
boto: None
pandas_datareader: None

@TomAugspurger
Copy link
Contributor

@danfrankj I have a branch here that fixes this. I'll make sure to have it in before our next release. The generated HTML should be much nicer to view as well (less whitespace and careless indenting).

@TomAugspurger
Copy link
Contributor

Closed by #15954

In [3]: df
Out[3]:
   A       B       C
0  1  0.5021 -1.8989
1  0 -0.0123  0.4893
2  0 -1.0470 -0.9169

In [4]: print(df.style.set_caption('example').render())
<style  type="text/css" >
</style>
<table id="T_dd1e2328_21f7_11e7_995e_186590cd1c87" ><caption>example</caption>
<thead>    <tr>
        <th class="blank level0" ></th>
        <th class="col_heading level0 col0" >A</th>
        <th class="col_heading level0 col1" >B</th>
        <th class="col_heading level0 col2" >C</th>
    </tr></thead>
<tbody>    <tr>
        <th id="T_dd1e2328_21f7_11e7_995e_186590cd1c87" class="row_heading level0 row0" >0</th>
        <td id="T_dd1e2328_21f7_11e7_995e_186590cd1c87row0_col0" class="data row0 col0" >1</td>
        <td id="T_dd1e2328_21f7_11e7_995e_186590cd1c87row0_col1" class="data row0 col1" >0.5021</td>
        <td id="T_dd1e2328_21f7_11e7_995e_186590cd1c87row0_col2" class="data row0 col2" >-1.8989</td>
    </tr>    <tr>
        <th id="T_dd1e2328_21f7_11e7_995e_186590cd1c87" class="row_heading level0 row1" >1</th>
        <td id="T_dd1e2328_21f7_11e7_995e_186590cd1c87row1_col0" class="data row1 col0" >0</td>
        <td id="T_dd1e2328_21f7_11e7_995e_186590cd1c87row1_col1" class="data row1 col1" >-0.0123</td>
        <td id="T_dd1e2328_21f7_11e7_995e_186590cd1c87row1_col2" class="data row1 col2" >0.4893</td>
    </tr>    <tr>
        <th id="T_dd1e2328_21f7_11e7_995e_186590cd1c87" class="row_heading level0 row2" >2</th>
        <td id="T_dd1e2328_21f7_11e7_995e_186590cd1c87row2_col0" class="data row2 col0" >0</td>
        <td id="T_dd1e2328_21f7_11e7_995e_186590cd1c87row2_col1" class="data row2 col1" >-1.047</td>
        <td id="T_dd1e2328_21f7_11e7_995e_186590cd1c87row2_col2" class="data row2 col2" >-0.9169</td>
    </tr></tbody>
</table>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO HTML read_html, to_html, Styler.apply, Styler.applymap
Projects
None yet
Development

No branches or pull requests

2 participants