Description
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
The current _repr_html_
implementation in dataframe.rs
embeds HTML rendering logic directly in Rust. This design tightly couples the rendering logic with the DataFrame internals, making it difficult to customize the output or apply different styling rules.
This results in inflexibility for users who wish to tailor the HTML output for their environment or disable it entirely.
Describe the solution you'd like
Introduce a configurable Python-based HTML formatter for DataFrame visualization, which includes the following components:
- A new Python module
datafusion/html_formatter.py
- A
DataFrameHtmlFormatter
class responsible for rendering options such as cell truncation, CSS styling, and interactivity - A global formatter instance with an accessible configuration API
The Rust-side _repr_html_
will be modified to:
- Call the Python formatter
- Return the resulting HTML for Jupyter or rich display contexts
Users will be able to globally configure the formatter like so:
import datafusion as df
df.configure_formatter(
max_cell_length=50,
enable_cell_expansion=False,
custom_css="table { font-family: Arial; }"
)
Describe alternatives you've considered
-
Continuing to manage HTML formatting logic in Rust, but this reduces flexibility and is harder to maintain
-
Using third-party libraries like pandas-style renderers, but this introduces dependency complexity and integration issues
-
Avoiding customization altogether, which limits user control and mismatches with modern expectations for interactive environments
Additional context
This was motivated by @timsaucer 's suggestion here.
This change aligns with a modular design philosophy, improves maintainability, and empowers users to better control their development experience. By decoupling visualization logic from Rust internals, it ensures better separation of concerns and enables easier integration with Python-based tools and environments.
Open Questions:
Should backward compatibility with the current rendering be maintained?
What default styling options should be included out of the box?
Should per-DataFrame styling overrides be supported in addition to global configuration?