Skip to content
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

Make DataFrame.to_html output full content #17004

Closed
dclong opened this issue Jul 18, 2017 · 6 comments · Fixed by #24841
Closed

Make DataFrame.to_html output full content #17004

dclong opened this issue Jul 18, 2017 · 6 comments · Fixed by #24841
Labels
Enhancement IO HTML read_html, to_html, Styler.apply, Styler.applymap
Milestone

Comments

@dclong
Copy link

dclong commented Jul 18, 2017

Make DataFrame.to_html output full contents by default. Or at least add option to enable outputting full content.

Code Sample

import pandas as pd
df = pd.DataFrame({
    'id': [1, 2, 3, 4, 5],
    'link': ['http://a_super_loooooooooooooooooooooooooooooooong_link.com', '', '', '', '']
})
df.to_html('df.html')

Problem description

By default, pandas uses a short representation of a very long string. However, when outputting to HTML, I think users expect the full content to be outputted rather than a short representation.

Expected Output

Full content output is expected. Or least there should be an option to enable outputting full content.

@gfyoung gfyoung added IO HTML read_html, to_html, Styler.apply, Styler.applymap Enhancement labels Jul 18, 2017
@gfyoung
Copy link
Member

gfyoung commented Jul 18, 2017

This reminds me of #16911, though I'm not sure if they're completely related. I agree that we should also try to truncate based on column length and not just the number of columns.

cc @jreback

@gfyoung
Copy link
Member

gfyoung commented Jul 18, 2017

@dclong : If you have ideas how to go out implementing such a feature, PR's are welcome!

@DataYI
Copy link

DataYI commented Nov 15, 2018

The default max_colwidth is 50, and you can set it to a larger number. @dclong

import pandas as pd

pd.options.display.max_colwidth = 100
df = pd.DataFrame({
    'id': [1, 2, 3, 4, 5],
    'link': ['http://a_super_loooooooooooooooooooooooooooooooong_link.com', '', '', '', '']
})
df.to_html('df.html')

@glemaitre
Copy link
Contributor

I stumble into this issue. I would have expected to pass the parameter max_colwidth to the to_html method similar to the max_cols and max_rows.

I was wondering which kind of user API would be the best there.

ping @jorisvandenbossche

@simonjayhawkins
Copy link
Member

I would think that the default should be to ignore the display.max_colwidth when using to_html(), but this would then prevent users having the ability to truncate the output.

so maybe an additional max_colwidth as @glemaitre suggests having the default value of None to ignore display.max_colwidth, a value of True to honor the display.max_colwidth value, or accept an int to override the display.max_colwidth.

@simonjayhawkins
Copy link
Member

a simpler api would be just max_colwidth: bool default False, we have the set_option and option_context to allow changing the value.

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

Successfully merging a pull request may close this issue.

6 participants