[pandas-styles] is to be used on questions about Table Visualization using pandas built-in Styler object (df.style). Be sure to also include the tag [pandas].
Pandas has built-in support for creating styled tables which can be viewed in environments which support it like Jupyter Notebooks or exported to Excel, LaTeX, or HTML.
The result of table styles is a styled object which is no longer a DataFrame. Styling should be applied after all data processing has been completed as the resulting styled object will not have access to DataFrame data processing methods.
The documentation on Table Visualization covers the features offered.
Direct Links to Common Formatting Operations:
- Formatting the Display
- Format the text display for the underlying values in the DataFrame.
- Table Styles
- Use CSS to define styles for the table as a whole.
- Styler Functions
- Use
pandas
logic operations to conditionally apply CSS styles to cells, rows, and/or columns in the DataFrame
- Use
- Tooltips and Captions
- Builtin Styles
- Common styling operations that are included in the Styler
- Export to Excel
- Export to LaTeX
- Export to HTML
- DataFrame only (use Series.to_frame().style)
- The index and columns do not need to be unique, but certain styling functions can only work with unique indexes.
- No large repr, and construction performance isn’t great; although we have some HTML optimizations
- You can only apply styles, you can’t insert new HTML entities, except via subclassing.