Skip to content

Commit b5e38e1

Browse files
committed
Update html_formatter documentation
1 parent c0f5aa8 commit b5e38e1

1 file changed

Lines changed: 45 additions & 7 deletions

File tree

docs/source/user-guide/dataframe.rst

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,17 @@ You can customize how DataFrames are rendered in HTML by configuring the formatt
7575
7676
# Change the default styling
7777
configure_formatter(
78-
max_rows=50, # Maximum number of rows to display
79-
max_width=None, # Maximum width in pixels (None for auto)
80-
theme="light", # Theme: "light" or "dark"
81-
precision=2, # Floating point precision
82-
thousands_separator=",", # Separator for thousands
83-
date_format="%Y-%m-%d", # Date format
84-
truncate_width=20 # Max width for string columns before truncating
78+
max_cell_length=25, # Maximum characters in a cell before truncation
79+
max_width=1000, # Maximum width in pixels
80+
max_height=300, # Maximum height in pixels
81+
max_memory_bytes=2097152, # Maximum memory for rendering (2MB)
82+
min_rows_display=20, # Minimum number of rows to display
83+
repr_rows=10, # Number of rows to display in __repr__
84+
enable_cell_expansion=True,# Allow expanding truncated cells
85+
custom_css=None, # Additional custom CSS
86+
show_truncation_message=True, # Show message when data is truncated
87+
style_provider=None, # Custom styling provider
88+
use_shared_styles=True # Share styles across tables
8589
)
8690
8791
The formatter settings affect all DataFrames displayed after configuration.
@@ -113,6 +117,25 @@ For advanced styling needs, you can create a custom style provider:
113117
# Apply the custom style provider
114118
configure_formatter(style_provider=MyStyleProvider())
115119
120+
Performance Optimization with Shared Styles
121+
-------------------------------------------
122+
The ``use_shared_styles`` parameter (enabled by default) optimizes performance when displaying
123+
multiple DataFrames in notebook environments:
124+
125+
.. code-block:: python
126+
from datafusion.html_formatter import StyleProvider, configure_formatter
127+
# Default: Use shared styles (recommended for notebooks)
128+
configure_formatter(use_shared_styles=True)
129+
130+
# Disable shared styles (each DataFrame includes its own styles)
131+
configure_formatter(use_shared_styles=False)
132+
133+
When ``use_shared_styles=True``:
134+
- CSS styles and JavaScript are included only once per notebook session
135+
- This reduces HTML output size and prevents style duplication
136+
- Improves rendering performance with many DataFrames
137+
- Applies consistent styling across all DataFrames
138+
116139
Creating a Custom Formatter
117140
---------------------------
118141

@@ -177,3 +200,18 @@ You can also use a context manager to temporarily change formatting settings:
177200
178201
# Back to default formatting
179202
df.show()
203+
204+
Memory and Display Controls
205+
---------------------------
206+
207+
You can control how much data is displayed and how much memory is used for rendering:
208+
209+
.. code-block:: python
210+
211+
configure_formatter(
212+
max_memory_bytes=4 * 1024 * 1024, # 4MB maximum memory for display
213+
min_rows_display=50, # Always show at least 50 rows
214+
repr_rows=20 # Show 20 rows in __repr__ output
215+
)
216+
217+
These parameters help balance comprehensive data display against performance considerations.

0 commit comments

Comments
 (0)