-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Add table id option to pandas.DataFrame.to_html #8496
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
Comments
We are looking for a more general soln (I pointed to some related issues). If you have some ideas, pls post/indicate! |
I'm not sure my py skills are up to contributing code but if I can abstract anything from use cases I come across I'll add them in to an appropriate thread. Something that comes to mind in terms of generalisation is how to cope with outputting metadata, either about the dataframe itself, or additional to the dataframe in terms of presentation (for example, the id attribute for the table, or column layout information etc). The ONS (Office of National Statistics) in the UK have started experimenting with the Tabular Data Package format which bundles a JSON file carrying metadata about the contents of one or more CSV files with those files packaged alongside it. I've been wondering what a pandas (How to make effective use of all the metadata when doing a It seems to me that there are perhaps three sorts of metadata that need addressing in outputs:
|
Hello, I was also looking for the same feature because I'm using Flask and want to output a DataFrame as HTML and have a nice formatting using a JS library for table. So I will need to refer to a given id in my JS code. Having just an id parameter will help. I understand the wish for a more general solution but it will be a pragmatic solution Here is my own version (to support for example escape parameter also) def df_to_html_with_id(df, id, *args, **kwargs):
s = df.to_html(*args, **kwargs)
return s[:7] + 'id="%s" ' % id + s[7:] Kind regards |
I'm using the pandas.DataFrame.to_html() method to generate a table to embed into a a templated document which references the table via an id. It would be useful if pandas.DataFrame.to_html() supported a
table_id
parameter:df.to_html(table_id='myTable')
to produce:
<table border="1" class="dataframe" id='mytable'>
The text was updated successfully, but these errors were encountered: