pl2html 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pl2html-0.3.0 → pl2html-0.4.0}/PKG-INFO +5 -8
- {pl2html-0.3.0 → pl2html-0.4.0}/README.md +4 -7
- {pl2html-0.3.0 → pl2html-0.4.0}/pl2html/__init__.py +11 -5
- {pl2html-0.3.0 → pl2html-0.4.0}/pyproject.toml +1 -1
- {pl2html-0.3.0 → pl2html-0.4.0}/pl2html/formats.py +0 -0
- {pl2html-0.3.0 → pl2html-0.4.0}/pl2html/styles.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pl2html
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Add your description here
|
|
5
5
|
Requires-Dist: polars>=1.42.1
|
|
6
6
|
Requires-Python: >=3.14
|
|
@@ -51,10 +51,8 @@ df = pl.DataFrame(
|
|
|
51
51
|
)
|
|
52
52
|
|
|
53
53
|
# Compiles safely to a Polars LazyFrame containing the HTML output
|
|
54
|
-
|
|
54
|
+
html_table_string = to_html(df)
|
|
55
55
|
|
|
56
|
-
# Collect and extract the compiled string
|
|
57
|
-
html_table_string = html_lazy.collect().item()
|
|
58
56
|
print(html_table_string)
|
|
59
57
|
```
|
|
60
58
|
|
|
@@ -101,7 +99,7 @@ df_f = df.with_columns(
|
|
|
101
99
|
fmt.sub_zero("status_code", zero_text="OK")
|
|
102
100
|
)
|
|
103
101
|
|
|
104
|
-
html = to_html(df_f)
|
|
102
|
+
html = to_html(df_f)
|
|
105
103
|
```
|
|
106
104
|
|
|
107
105
|
### 3. Advanced Styling via Native Attributes (`attrs`)
|
|
@@ -141,7 +139,7 @@ styles.update(
|
|
|
141
139
|
)
|
|
142
140
|
)
|
|
143
141
|
|
|
144
|
-
html_table = to_html(df, attrs=styles)
|
|
142
|
+
html_table = to_html(df, attrs=styles)
|
|
145
143
|
```
|
|
146
144
|
|
|
147
145
|
Output (github may override table colors, but they are there):
|
|
@@ -213,5 +211,4 @@ Most of the API design and formatting parameters in this library are heavily ins
|
|
|
213
211
|
However, this library was born out of distinct architectural and environment constraints:
|
|
214
212
|
|
|
215
213
|
* **Zero Overhead Styling:** While `great-tables` is incredibly feature-rich, it often produces dense HTML styles and boilerplate structures that were unnecessary for the target use cases. This library optimizes for minimal, highly clean HTML output.
|
|
216
|
-
* **Modern Python Compatibility (Py 3.14+):** `great-tables` pulls in heavy external dependencies, including binary wheels like `multimark`. At the time of development, these dependencies did not support Python 3.14. To unblock workflows and maintain an ultra-lightweight, future-proof stack with zero complex binary dependencies, this native, Rust-backed Polars formatter was built from the ground up.
|
|
217
|
-
|
|
214
|
+
* **Modern Python Compatibility (Py 3.14+):** `great-tables` pulls in heavy external dependencies, including binary wheels like `multimark`. At the time of development, these dependencies did not support Python 3.14 (see [multimark #3](https://github.com/posit-dev/multimark/issues/3)). To unblock workflows and maintain an ultra-lightweight, future-proof stack with zero complex binary dependencies, this native, Rust-backed Polars formatter was built from the ground up.
|
|
@@ -42,10 +42,8 @@ df = pl.DataFrame(
|
|
|
42
42
|
)
|
|
43
43
|
|
|
44
44
|
# Compiles safely to a Polars LazyFrame containing the HTML output
|
|
45
|
-
|
|
45
|
+
html_table_string = to_html(df)
|
|
46
46
|
|
|
47
|
-
# Collect and extract the compiled string
|
|
48
|
-
html_table_string = html_lazy.collect().item()
|
|
49
47
|
print(html_table_string)
|
|
50
48
|
```
|
|
51
49
|
|
|
@@ -92,7 +90,7 @@ df_f = df.with_columns(
|
|
|
92
90
|
fmt.sub_zero("status_code", zero_text="OK")
|
|
93
91
|
)
|
|
94
92
|
|
|
95
|
-
html = to_html(df_f)
|
|
93
|
+
html = to_html(df_f)
|
|
96
94
|
```
|
|
97
95
|
|
|
98
96
|
### 3. Advanced Styling via Native Attributes (`attrs`)
|
|
@@ -132,7 +130,7 @@ styles.update(
|
|
|
132
130
|
)
|
|
133
131
|
)
|
|
134
132
|
|
|
135
|
-
html_table = to_html(df, attrs=styles)
|
|
133
|
+
html_table = to_html(df, attrs=styles)
|
|
136
134
|
```
|
|
137
135
|
|
|
138
136
|
Output (github may override table colors, but they are there):
|
|
@@ -204,5 +202,4 @@ Most of the API design and formatting parameters in this library are heavily ins
|
|
|
204
202
|
However, this library was born out of distinct architectural and environment constraints:
|
|
205
203
|
|
|
206
204
|
* **Zero Overhead Styling:** While `great-tables` is incredibly feature-rich, it often produces dense HTML styles and boilerplate structures that were unnecessary for the target use cases. This library optimizes for minimal, highly clean HTML output.
|
|
207
|
-
* **Modern Python Compatibility (Py 3.14+):** `great-tables` pulls in heavy external dependencies, including binary wheels like `multimark`. At the time of development, these dependencies did not support Python 3.14. To unblock workflows and maintain an ultra-lightweight, future-proof stack with zero complex binary dependencies, this native, Rust-backed Polars formatter was built from the ground up.
|
|
208
|
-
|
|
205
|
+
* **Modern Python Compatibility (Py 3.14+):** `great-tables` pulls in heavy external dependencies, including binary wheels like `multimark`. At the time of development, these dependencies did not support Python 3.14 (see [multimark #3](https://github.com/posit-dev/multimark/issues/3)). To unblock workflows and maintain an ultra-lightweight, future-proof stack with zero complex binary dependencies, this native, Rust-backed Polars formatter was built from the ground up.
|
|
@@ -10,7 +10,7 @@ from polars import (
|
|
|
10
10
|
when as _when,
|
|
11
11
|
)
|
|
12
12
|
|
|
13
|
-
__version__ = '0.
|
|
13
|
+
__version__ = '0.4.0'
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
def _escape_polars_string(col_name: str) -> _Expr:
|
|
@@ -126,7 +126,7 @@ def to_html(
|
|
|
126
126
|
*,
|
|
127
127
|
attrs: dict[str, dict[str, _Expr]] | None = None,
|
|
128
128
|
exclude_columns: list[str] | None = None,
|
|
129
|
-
) ->
|
|
129
|
+
) -> str:
|
|
130
130
|
"""
|
|
131
131
|
Compiles a Polars DataFrame safely into an HTML string layout.
|
|
132
132
|
Accepts structural custom attributes mappings to handle layout modifications natively.
|
|
@@ -151,8 +151,14 @@ def to_html(
|
|
|
151
151
|
# 4. Generate wrappers and frame the query graph
|
|
152
152
|
html_header, html_footer = _build_html_skeleton(visible_columns)
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
# 5. Execute the query graph and pull out the raw python string directly
|
|
155
|
+
return (
|
|
156
|
+
lf.select(row_expr.alias('html_row'))
|
|
157
|
+
.select(
|
|
158
|
+
(
|
|
159
|
+
html_header + _col('html_row').str.join('\n') + html_footer
|
|
160
|
+
).alias('html_table')
|
|
157
161
|
)
|
|
162
|
+
.collect()
|
|
163
|
+
.item()
|
|
158
164
|
)
|
|
File without changes
|
|
File without changes
|