{"id":4177,"library":"pretty-html-table","title":"Pretty HTML Table for Pandas DataFrames","description":"pretty-html-table (v0.9.16) is a Python library designed to convert pandas DataFrames into aesthetically pleasing HTML tables, primarily for use in email reports. It offers 12 different color themes and formats HTML at the DataFrame row level to ensure broad compatibility across various email providers, avoiding common CSS rendering issues. The library is currently in maintenance mode with infrequent releases, with the last significant update in April 2022.","status":"maintenance","version":"0.9.16","language":"en","source_language":"en","source_url":"https://github.com/sbi-rviot/ph_table","tags":["pandas","html","table","email","reporting","styling"],"install":[{"cmd":"pip install pretty-html-table","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"The library's core functionality is to convert pandas DataFrames to HTML tables.","package":"pandas","optional":false}],"imports":[{"symbol":"build_table","correct":"from pretty_html_table import build_table"}],"quickstart":{"code":"import pandas as pd\nfrom pretty_html_table import build_table\n\n# Create a sample pandas DataFrame\ndata = {\n    'Name': ['Alice', 'Bob', 'Charlie'],\n    'Age': [24, 27, 22],\n    'City': ['New York', 'Los Angeles', 'Chicago']\n}\ndf = pd.DataFrame(data)\n\n# Convert the DataFrame to a pretty HTML table with a 'blue_light' theme\nhtml_table = build_table(df, 'blue_light', width='auto', font_size='medium', text_align='left')\n\n# Print the HTML table (for demonstration)\nprint(html_table)\n\n# Optionally, save to an HTML file\n# with open('pretty_table.html', 'w') as f:\n#    f.write(html_table)\n# print(\"HTML table saved to pretty_table.html\")","lang":"python","description":"This quickstart demonstrates how to create a pandas DataFrame and then convert it into a styled HTML table using `build_table`. The resulting HTML string can be printed, saved to a file, or embedded directly into an email body."},"warnings":[{"fix":"Refer to your email client's API documentation for the correct property to send HTML content. For many Python email libraries, ensure the `Content-Type` header is set to `text/html`.","message":"When embedding the generated HTML into emails, ensure you use the `HTMLBody` property (e.g., `mail.HTMLBody` for Outlook objects) rather than `Body` to correctly render the table. Using `Body` will typically display the raw HTML text.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For complex web-based table designs requiring full CSS control or responsiveness, consider other libraries or direct CSS implementations. pretty-html-table is optimized for email embeddability.","message":"The library prioritizes compatibility with email clients by applying styles at the HTML table row level, rather than relying heavily on external CSS. This approach ensures consistent rendering across many email services but means advanced CSS customizations or responsive design patterns typically used for web pages might not be directly supported or effective.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify that `len(width_dict)` is equal to `len(df.columns)` before passing it to `build_table`.","message":"When using the `width_dict` argument to set custom column widths, the provided list of width strings (e.g., `['100px', 'auto', '300px']`) must have a length exactly matching the number of columns in your pandas DataFrame. An incorrect length will lead to unexpected or unapplied width styles.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Evaluate the current functionality against your needs. For long-term projects requiring active support or cutting-edge features, consider the maintenance status when making your choice.","message":"The library appears to be in maintenance mode. The last PyPI release (v0.9.16) was in April 2022, and the GitHub repository shows the last significant commit approximately four years prior. While functional, active development for new features or rapid bug fixes may be limited.","severity":"gotcha","affected_versions":"0.9.16 and potentially future versions if maintenance continues at this pace"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}