df2tables 0.3.3__tar.gz → 0.3.4__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.
@@ -0,0 +1,8 @@
1
+ # demo/example outputs - never commit these (examples write to cwd / $HOME)
2
+ /*.html
3
+ /__pycache__/
4
+ *.pyc
5
+ /dist/
6
+ *.egg-info/
7
+ .ipynb_checkpoints/
8
+ *.tgz
@@ -1,32 +1,11 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: df2tables
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Summary: df2tables: Pandas and Polars DataFrames to Interactive DataTables
5
5
  Project-URL: Homepage, https://github.com/ts-kontakt/df2tables
6
6
  Project-URL: Issues, https://github.com/ts-kontakt/df2tables/issues
7
7
  Author-email: Tomasz Sługocki <ts.kontakt@gmail.com>
8
- License: MIT License
9
-
10
- Copyright (c) 2024 Tomasz Sługocki
11
-
12
- Permission is hereby granted, free of charge, to any person obtaining a copy
13
- of this software and associated documentation files (the "Software"), to deal
14
- in the Software without restriction, including without limitation the rights
15
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- copies of the Software, and to permit persons to whom the Software is
17
- furnished to do so, subject to the following conditions:
18
-
19
- The above copyright notice and this permission notice shall be included in all
20
- copies or substantial portions of the Software.
21
-
22
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- SOFTWARE.
29
- License-File: LICENSE
8
+ License-Expression: MIT
30
9
  Keywords: DataTables,HTML,Javascript,Pandas,Polars
31
10
  Classifier: Programming Language :: Python :: 3
32
11
  Classifier: Programming Language :: Python :: 3.10
@@ -105,7 +84,7 @@ output_path = df2t.render_sample_df(to_file="sample_table.html")
105
84
  # Polars sample instead of the pandas default
106
85
  output_path = df2t.render_sample_df(df_type="polars", to_file="sample_table_pl.html")
107
86
  ```
108
- *The underlying generator, `get_sample_df(df_type="pandas", size=50)`, is also available directly if you just want the sample DataFrame without rendering it.*
87
+ *The underlying generator, `get_sample_df(df_type="pandas", size=50, seed=None)`, is also available directly if you just want the sample DataFrame without rendering it - pass `seed=<int>` for a reproducible frame.*
109
88
 
110
89
  ### Rendering in notebook
111
90
  ```python
@@ -168,6 +147,8 @@ df2t.render(
168
147
  - `scroll_x` (bool): Enable horizontal scrolling (default: True)
169
148
  - `scroll_y` (str | None): Vertical scrolling height, e.g. `"70vh"`; set to `None` to disable (default: "70vh")
170
149
  - `scroll_collapse` (bool): Collapse the container height when there are fewer rows than `scroll_y` (default: True)
150
+ - `list_preview` (int): How many elements of a list/dict cell are shown in its basic preview before the tail is elided (default: 5)
151
+ - `paging_warn_limit` (int | None): Row-count threshold for the in-page performance warning when paging is disabled; `None` keeps the template default (500) (default: None)
171
152
 
172
153
  **Returns:**
173
154
 
@@ -307,7 +288,8 @@ The endpoint at `data_url` should return JSON in one of two shapes: a bare array
307
288
  df2t.to_js_array(
308
289
  df: pd.DataFrame | pl.DataFrame,
309
290
  precision: int = 2,
310
- raw: bool = False
291
+ raw: bool = False,
292
+ list_preview: int = 5
311
293
  ) -> Union[str, list]
312
294
  ```
313
295
 
@@ -317,14 +299,15 @@ Converts a pandas/polars DataFrame to a JavaScript array-of-arrays (strict JSON)
317
299
 
318
300
  - `df`: pandas or polars DataFrame
319
301
  - `precision`: rounding precision for float columns, same meaning as in `render()` (default: 2)
320
- - `raw`: if `True`, returns the plain (already NaN/inf-cleaned) Python list of lists instead of a JSON string - convenient for frameworks that JSON-encode the response themselves, e.g. Flask's `jsonify()` (default: False)
302
+ - `raw`: if `True`, returns the plain (already labelled) Python list of lists instead of a JSON string - convenient for frameworks that JSON-encode the response themselves, e.g. Flask's `jsonify()` (default: False)
303
+ - `list_preview`: how many elements of a list/dict cell are shown in its basic preview (default: 5)
321
304
 
322
305
  **Returns:**
323
306
 
324
307
  - `str`: JSON string like `'[[1,"a",3.5],[2,"b",4.1]]'` (default)
325
308
  - `list`: the underlying list of lists, when `raw=True`
326
309
 
327
- `NaN`/`inf` float values are always converted to `null`/`None`, so the result always round-trips through `JSON.parse()` / `jsonify()` without error.
310
+ Missing values of every flavour (`None`, `pd.NA`, `NaT`, ...) carry the single `"NA"` label; non-finite floats keep their names (`"NaN"`, `"inf"`, `"-inf"`). List/dict cells show a bounded basic preview like `'[0, 1, 2, 3, 4, ...]'`. No bare `NaN`/`Infinity` token is ever emitted, so the result always round-trips through `JSON.parse()` / `jsonify()` without error.
328
311
 
329
312
  **Example (Flask):**
330
313
 
@@ -352,7 +335,7 @@ except (ValueError, TypeError, FileNotFoundError, RuntimeError, OSError) as e:
352
335
  print(f"Could not render table: {e}")
353
336
  ```
354
337
 
355
- Only genuinely unknown keyword arguments are non-fatal - they emit a `UserWarning` and are ignored rather than raising.
338
+ Only genuinely unknown keyword arguments are non-fatal - they emit a `UserWarning` and are ignored rather than raising. Unknown `render_opts` keys likewise emit a `UserWarning` and have no effect.
356
339
 
357
340
  ### Deprecated Arguments
358
341
 
@@ -360,7 +343,7 @@ The following are kept for backward compatibility but will be removed in a futur
360
343
 
361
344
  - `load_column_control` and `display_logo` as direct keyword arguments to `render()` / `render_ajax()` - pass them inside `render_opts={...}` instead
362
345
  - `num_html` - renamed to `format_negatives`; pass `format_negatives=...` instead
363
- - `load_datatables()` - a no-op kept for old imports; it hasn't been needed since v0.1.8
346
+ - `load_datatables()` - **removed** (it was a no-op and hasn't been needed since v0.1.8); any remaining import of it now fails - just delete it
364
347
 
365
348
  ## Configure DataTables directly from Python using `js_opts`
366
349
 
@@ -63,7 +63,7 @@ output_path = df2t.render_sample_df(to_file="sample_table.html")
63
63
  # Polars sample instead of the pandas default
64
64
  output_path = df2t.render_sample_df(df_type="polars", to_file="sample_table_pl.html")
65
65
  ```
66
- *The underlying generator, `get_sample_df(df_type="pandas", size=50)`, is also available directly if you just want the sample DataFrame without rendering it.*
66
+ *The underlying generator, `get_sample_df(df_type="pandas", size=50, seed=None)`, is also available directly if you just want the sample DataFrame without rendering it - pass `seed=<int>` for a reproducible frame.*
67
67
 
68
68
  ### Rendering in notebook
69
69
  ```python
@@ -126,6 +126,8 @@ df2t.render(
126
126
  - `scroll_x` (bool): Enable horizontal scrolling (default: True)
127
127
  - `scroll_y` (str | None): Vertical scrolling height, e.g. `"70vh"`; set to `None` to disable (default: "70vh")
128
128
  - `scroll_collapse` (bool): Collapse the container height when there are fewer rows than `scroll_y` (default: True)
129
+ - `list_preview` (int): How many elements of a list/dict cell are shown in its basic preview before the tail is elided (default: 5)
130
+ - `paging_warn_limit` (int | None): Row-count threshold for the in-page performance warning when paging is disabled; `None` keeps the template default (500) (default: None)
129
131
 
130
132
  **Returns:**
131
133
 
@@ -265,7 +267,8 @@ The endpoint at `data_url` should return JSON in one of two shapes: a bare array
265
267
  df2t.to_js_array(
266
268
  df: pd.DataFrame | pl.DataFrame,
267
269
  precision: int = 2,
268
- raw: bool = False
270
+ raw: bool = False,
271
+ list_preview: int = 5
269
272
  ) -> Union[str, list]
270
273
  ```
271
274
 
@@ -275,14 +278,15 @@ Converts a pandas/polars DataFrame to a JavaScript array-of-arrays (strict JSON)
275
278
 
276
279
  - `df`: pandas or polars DataFrame
277
280
  - `precision`: rounding precision for float columns, same meaning as in `render()` (default: 2)
278
- - `raw`: if `True`, returns the plain (already NaN/inf-cleaned) Python list of lists instead of a JSON string - convenient for frameworks that JSON-encode the response themselves, e.g. Flask's `jsonify()` (default: False)
281
+ - `raw`: if `True`, returns the plain (already labelled) Python list of lists instead of a JSON string - convenient for frameworks that JSON-encode the response themselves, e.g. Flask's `jsonify()` (default: False)
282
+ - `list_preview`: how many elements of a list/dict cell are shown in its basic preview (default: 5)
279
283
 
280
284
  **Returns:**
281
285
 
282
286
  - `str`: JSON string like `'[[1,"a",3.5],[2,"b",4.1]]'` (default)
283
287
  - `list`: the underlying list of lists, when `raw=True`
284
288
 
285
- `NaN`/`inf` float values are always converted to `null`/`None`, so the result always round-trips through `JSON.parse()` / `jsonify()` without error.
289
+ Missing values of every flavour (`None`, `pd.NA`, `NaT`, ...) carry the single `"NA"` label; non-finite floats keep their names (`"NaN"`, `"inf"`, `"-inf"`). List/dict cells show a bounded basic preview like `'[0, 1, 2, 3, 4, ...]'`. No bare `NaN`/`Infinity` token is ever emitted, so the result always round-trips through `JSON.parse()` / `jsonify()` without error.
286
290
 
287
291
  **Example (Flask):**
288
292
 
@@ -310,7 +314,7 @@ except (ValueError, TypeError, FileNotFoundError, RuntimeError, OSError) as e:
310
314
  print(f"Could not render table: {e}")
311
315
  ```
312
316
 
313
- Only genuinely unknown keyword arguments are non-fatal - they emit a `UserWarning` and are ignored rather than raising.
317
+ Only genuinely unknown keyword arguments are non-fatal - they emit a `UserWarning` and are ignored rather than raising. Unknown `render_opts` keys likewise emit a `UserWarning` and have no effect.
314
318
 
315
319
  ### Deprecated Arguments
316
320
 
@@ -318,7 +322,7 @@ The following are kept for backward compatibility but will be removed in a futur
318
322
 
319
323
  - `load_column_control` and `display_logo` as direct keyword arguments to `render()` / `render_ajax()` - pass them inside `render_opts={...}` instead
320
324
  - `num_html` - renamed to `format_negatives`; pass `format_negatives=...` instead
321
- - `load_datatables()` - a no-op kept for old imports; it hasn't been needed since v0.1.8
325
+ - `load_datatables()` - **removed** (it was a no-op and hasn't been needed since v0.1.8); any remaining import of it now fails - just delete it
322
326
 
323
327
  ## Configure DataTables directly from Python using `js_opts`
324
328
 
@@ -1,5 +1,5 @@
1
1
  from .df2tables import *
2
- __version__ = "0.3.3"
2
+ __version__ = "0.3.4"
3
3
  __author__ = "Tomasz Slugocki"
4
4
  __license__ = "MIT"
5
5