Skip to content

Commit 4d8da3d

Browse files
committed
Rename html_formatter to dataframe_formatter
1 parent 0f48cb5 commit 4d8da3d

File tree

6 files changed

+26
-13
lines changed

6 files changed

+26
-13
lines changed

docs/source/api/dataframe.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ HTML Rendering Customization
174174
----------------------------
175175

176176
DataFusion provides extensive customization options for HTML table rendering through the
177-
``datafusion.html_formatter`` module.
177+
``datafusion.dataframe_formatter`` module.
178178

179179
Configuring the HTML Formatter
180180
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -183,7 +183,7 @@ You can customize how DataFrames are rendered by configuring the formatter:
183183

184184
.. code-block:: python
185185
186-
from datafusion.html_formatter import configure_formatter
186+
from datafusion.dataframe_formatter import configure_formatter
187187
188188
configure_formatter(
189189
max_cell_length=30, # Maximum length of cell content before truncation
@@ -206,7 +206,7 @@ For advanced styling needs, you can create a custom style provider class:
206206

207207
.. code-block:: python
208208
209-
from datafusion.html_formatter import configure_formatter
209+
from datafusion.dataframe_formatter import configure_formatter
210210
211211
class CustomStyleProvider:
212212
def get_cell_style(self) -> str:
@@ -225,7 +225,7 @@ You can register custom formatters for specific data types:
225225

226226
.. code-block:: python
227227
228-
from datafusion.html_formatter import get_formatter
228+
from datafusion.dataframe_formatter import get_formatter
229229
230230
formatter = get_formatter()
231231
@@ -285,7 +285,7 @@ The HTML formatter maintains global state that can be managed:
285285

286286
.. code-block:: python
287287
288-
from datafusion.html_formatter import reset_formatter, reset_styles_loaded_state, get_formatter
288+
from datafusion.dataframe_formatter import reset_formatter, reset_styles_loaded_state, get_formatter
289289
290290
# Reset the formatter to default settings
291291
reset_formatter()
@@ -303,7 +303,7 @@ This example shows how to create a dashboard-like styling for your DataFrames:
303303

304304
.. code-block:: python
305305
306-
from datafusion.html_formatter import configure_formatter, get_formatter
306+
from datafusion.dataframe_formatter import configure_formatter, get_formatter
307307
308308
# Define custom CSS
309309
custom_css = """

python/datafusion/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@
4747
SQLOptions,
4848
)
4949
from .dataframe import DataFrame, ParquetColumnOptions, ParquetWriterOptions
50+
from .dataframe_formatter import configure_formatter
5051
from .expr import (
5152
Expr,
5253
WindowFrame,
5354
)
54-
from .html_formatter import configure_formatter
5555
from .io import read_avro, read_csv, read_json, read_parquet
5656
from .plan import ExecutionPlan, LogicalPlan
5757
from .record_batch import RecordBatch, RecordBatchStream

python/datafusion/dataframe.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import polars as pl
5353
import pyarrow as pa
5454

55-
from datafusion._internal import DataFrame as DataFrameInternal
5655
from datafusion._internal import expr as expr_internal
5756

5857
from enum import Enum
@@ -1112,3 +1111,17 @@ def fill_null(self, value: Any, subset: list[str] | None = None) -> DataFrame:
11121111
- For columns not in subset, the original column is kept unchanged
11131112
"""
11141113
return DataFrame(self.df.fill_null(value, subset))
1114+
1115+
@staticmethod
1116+
def default_str_repr(
1117+
batches: list[pa.RecordBatch],
1118+
schema: pa.Schema,
1119+
has_more: bool,
1120+
table_uuid: str | None = None,
1121+
) -> str:
1122+
"""Return the default string representation of a DataFrame.
1123+
1124+
This method is used by the default formatter and implemented in Rust for
1125+
performance reasons.
1126+
"""
1127+
return DataFrameInternal.default_str_repr(batches, schema, has_more, table_uuid)

python/datafusion/html_formatter.py renamed to python/datafusion/dataframe_formatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def is_styles_loaded(cls) -> bool:
271271
True if styles have been loaded, False otherwise
272272
273273
Example:
274-
>>> from datafusion.html_formatter import DataFrameHtmlFormatter
274+
>>> from datafusion.dataframe_formatter import DataFrameHtmlFormatter
275275
>>> DataFrameHtmlFormatter.is_styles_loaded()
276276
False
277277
"""

python/tests/test_dataframe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@
3737
from datafusion import (
3838
functions as f,
3939
)
40-
from datafusion.expr import Window
41-
from datafusion.html_formatter import (
40+
from datafusion.dataframe_formatter import (
4241
DataFrameHtmlFormatter,
4342
configure_formatter,
4443
get_formatter,
4544
reset_formatter,
4645
reset_styles_loaded_state,
4746
)
47+
from datafusion.expr import Window
4848
from pyarrow.csv import write_csv
4949

5050
MB = 1024 * 1024

src/dataframe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ fn get_python_formatter_with_config(py: Python) -> PyResult<PythonFormatter> {
151151
Ok(PythonFormatter { formatter, config })
152152
}
153153

154-
/// Get the Python formatter from the datafusion.html_formatter module
154+
/// Get the Python formatter from the datafusion.dataframe_formatter module
155155
fn import_python_formatter(py: Python) -> PyResult<Bound<'_, PyAny>> {
156-
let formatter_module = py.import("datafusion.html_formatter")?;
156+
let formatter_module = py.import("datafusion.dataframe_formatter")?;
157157
let get_formatter = formatter_module.getattr("get_formatter")?;
158158
get_formatter.call0()
159159
}

0 commit comments

Comments
 (0)