Simple request:

The DataFrame to_html method accepted a kwarg classes to specify CSS classes that should be applied to the output HTML <table>.

When using the new(ish) DataFrame .style approach, as far as I can tell, no such option exists. And it is not possible to work around this issue using the .set_table_styles approach, since my goal is to apply an existing bit of CSS to the table by giving it a class (rather than re-specifying all the styles for this specific table).

Thoughts?

Comment From: TomAugspurger

Does set_table_attributes work for you?

In [9]: df = pd.DataFrame({"A": [1, 2]})
In [10]: print(df.style.set_table_attributes('class="my-class"').render())
<style  type="text/css" >
</style>
<table id="T_f2f59dfe_791d_11e7_8bfd_186590cd1c87" class="my-class">   # <---- Here
<thead>    <tr>
        <th class="blank level0" ></th>
        <th class="col_heading level0 col0" >A</th>
    </tr></thead>
<tbody>    <tr>
        <th id="T_f2f59dfe_791d_11e7_8bfd_186590cd1c87" class="row_heading level0 row0" >0</th>
        <td id="T_f2f59dfe_791d_11e7_8bfd_186590cd1c87row0_col0" class="data row0 col0" >1</td>
    </tr>    <tr>
        <th id="T_f2f59dfe_791d_11e7_8bfd_186590cd1c87" class="row_heading level0 row1" >1</th>
        <td id="T_f2f59dfe_791d_11e7_8bfd_186590cd1c87row1_col0" class="data row1 col0" >2</td>
    </tr></tbody>
</table>

Comment From: 8one6

If you had a dollar for every time you solved some idiot's issue like you just did for me, I'm guessing you'd be a pretty rich guy right now.

On that note, is there an easy way for me to donate $1 to the pandas project every time this happens?

Comment From: gfyoung

If you had a dollar for every time you solved some idiot's issue like you just did for me, I'm guessing you'd be a pretty rich guy right now.

Hahaha. Don't be too hard on yourself. For your question, 50 cents would suffice. :smile:

Don't be too hard on yourself about this. pandas is a pretty massive library, so it's easy to overlook the many features that it has.

BTW, if you really do want to donate, here's the link. Contributions are welcome! https://pandas.pydata.org/donate.html