Skip to content

ENH: Html table export: Add of other attributes #6488

Closed
@Gjacquenot

Description

@Gjacquenot

The to_html method allows to specify a set of classes for table rendering

However, I would like to specify other attribute to the table markup

Typically I want to use the DataTables (table plug-in for jQuery) library, that requires another attribute for rendering table
Here is an example

https://datatables.net/release-datatables/examples/basic_init/multi_col_sort.html

In method write_result of class HTMLFormatter in pandas/core/format.py
there is this command that I would like to update with other attributes

    self.write('<table border="1" class="%s">' % ' '.join(_classes),
               indent)

I tweak it for my personal needs, and it looks like this.

    self.write('<table border="1" class="%s" id="example">' % ' '.join(_classes),
               indent)

But I would like to be more general.
I would like to give a dictionary to the to_html method that will expand and produce the line below.

Is it possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closing CandidateMay be closeable, needs more eyeballsEnhancementIO HTMLread_html, to_html, Styler.apply, Styler.applymapOutput-Formatting__repr__ of pandas objects, to_stringStylerconditional formatting using DataFrame.style

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions