pandas-plots 0.11.25__py3-none-any.whl → 0.11.27__py3-none-any.whl
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.
- pandas_plots/tbl.py +45 -5
- {pandas_plots-0.11.25.dist-info → pandas_plots-0.11.27.dist-info}/METADATA +2 -1
- pandas_plots-0.11.27.dist-info/RECORD +10 -0
- pandas_plots-0.11.25.dist-info/RECORD +0 -10
- {pandas_plots-0.11.25.dist-info → pandas_plots-0.11.27.dist-info}/LICENSE +0 -0
- {pandas_plots-0.11.25.dist-info → pandas_plots-0.11.27.dist-info}/WHEEL +0 -0
- {pandas_plots-0.11.25.dist-info → pandas_plots-0.11.27.dist-info}/top_level.txt +0 -0
pandas_plots/tbl.py
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
import math
|
5
5
|
import os
|
6
6
|
from collections import abc
|
7
|
+
from pathlib import Path
|
7
8
|
from typing import Literal, get_args
|
8
9
|
import numpy as np
|
9
10
|
|
@@ -12,6 +13,7 @@ import pandas as pd
|
|
12
13
|
import plotly.express as px
|
13
14
|
from plotly.subplots import make_subplots
|
14
15
|
from scipy import stats
|
16
|
+
import dataframe_image as dfi
|
15
17
|
|
16
18
|
from .hlp import wrap_text
|
17
19
|
|
@@ -268,6 +270,12 @@ def pivot_df(
|
|
268
270
|
kpi_rag_list: list[float] = None,
|
269
271
|
kpi_mode: KPI_LITERAL = None,
|
270
272
|
kpi_shape: Literal["squad", "circle"] = "squad",
|
273
|
+
show_as_pct: bool = False,
|
274
|
+
alter_font: bool = True,
|
275
|
+
font_size_th: int = 0,
|
276
|
+
font_size_td: int = 0,
|
277
|
+
png_path: str | Path = None,
|
278
|
+
png_conversion: Literal["chrome", "selenium"] = "selenium",
|
271
279
|
) -> pd.DataFrame:
|
272
280
|
"""
|
273
281
|
A function to pivot a DataFrame based on specified parameters hand over to the *show_num_df* function.
|
@@ -299,6 +307,12 @@ def pivot_df(
|
|
299
307
|
max_min_x: max value green, min valued red for x axis
|
300
308
|
kpi_rag_list: a list of floats indicating the thresholds for rag lights. The list should have 2 elements.
|
301
309
|
kpi_shape: a Literal indicating the shape of the KPIs ["squad", "circle"]
|
310
|
+
show_as_pct (bool, optional): Whether to show values as percentages. Defaults to False.
|
311
|
+
alter_font (bool, optional): Whether to alter the font. Defaults to True.
|
312
|
+
font_size_th (int, optional): The font size for the header. Defaults to 0.
|
313
|
+
font_size_td (int, optional): The font size for the table data. Defaults to 0.
|
314
|
+
png_path (str | Path, optional): The path to save the output PNG file. Defaults to None.
|
315
|
+
png_conversion (Literal["chrome", "selenium"], optional): The conversion method for the PNG file. Defaults to "selenium".
|
302
316
|
|
303
317
|
Returns:
|
304
318
|
pd.DataFrame: The pivoted DataFrame.
|
@@ -380,6 +394,13 @@ def pivot_df(
|
|
380
394
|
kpi_mode=kpi_mode,
|
381
395
|
kpi_rag_list=kpi_rag_list,
|
382
396
|
kpi_shape=kpi_shape,
|
397
|
+
show_as_pct=show_as_pct,
|
398
|
+
alter_font=alter_font,
|
399
|
+
font_size_th=font_size_th,
|
400
|
+
font_size_td=font_size_td,
|
401
|
+
png_path=png_path,
|
402
|
+
png_conversion=png_conversion,
|
403
|
+
|
383
404
|
)
|
384
405
|
|
385
406
|
|
@@ -398,6 +419,10 @@ def show_num_df(
|
|
398
419
|
kpi_shape: Literal["squad", "circle"] = "squad",
|
399
420
|
show_as_pct: bool = False,
|
400
421
|
alter_font: bool = True,
|
422
|
+
font_size_th: int = 0,
|
423
|
+
font_size_td: int = 0,
|
424
|
+
png_path: str | Path = None,
|
425
|
+
png_conversion: Literal["chrome", "selenium"] = "selenium",
|
401
426
|
):
|
402
427
|
"""
|
403
428
|
A function to display a DataFrame with various options for styling and formatting, including the ability to show totals, apply data bar coloring, and control the display precision.
|
@@ -423,6 +448,10 @@ def show_num_df(
|
|
423
448
|
- kpi_shape: a Literal indicating the shape of the KPIs ["squad", "circle"]
|
424
449
|
- show_as_pct: a boolean indicating whether to show value as percentage (only advised on values ~1)
|
425
450
|
- alter_font: a boolean indicating whether to alter the font family
|
451
|
+
- font_size_th: an integer indicating the font size for the header
|
452
|
+
- font_size_td: an integer indicating the font size for the table data
|
453
|
+
- png_path: a string or Path indicating the path to save the PNG file
|
454
|
+
- png_conversion: a Literal indicating the conversion method for the PNG file ["chrome", "selenium"]
|
426
455
|
|
427
456
|
The function returns a styled representation of the DataFrame.
|
428
457
|
"""
|
@@ -637,16 +666,23 @@ def show_num_df(
|
|
637
666
|
out.set_properties(**{"font-family": "Courier"})
|
638
667
|
|
639
668
|
# * apply fonts for th (inkl. index)
|
640
|
-
|
641
|
-
# ("font-size", "10pt"),
|
669
|
+
_props_th = [
|
642
670
|
# ("font-weight", "bold"),
|
643
|
-
# ("font-family", "Courier"),
|
644
671
|
("text-align", "right")
|
645
672
|
]
|
673
|
+
|
674
|
+
_props_td = [
|
675
|
+
("text-align", "right")
|
676
|
+
]
|
677
|
+
if font_size_th > 0:
|
678
|
+
_props_th.append(("font-size", f"{font_size_th}pt"))
|
679
|
+
if font_size_td > 0:
|
680
|
+
_props_td.append(("font-size", f"{font_size_td}pt"))
|
681
|
+
|
646
682
|
out.set_table_styles(
|
647
683
|
[
|
648
|
-
dict(selector="th", props=
|
649
|
-
|
684
|
+
dict(selector="th", props=_props_th),
|
685
|
+
dict(selector="td", props=_props_td),
|
650
686
|
]
|
651
687
|
)
|
652
688
|
|
@@ -657,6 +693,10 @@ def show_num_df(
|
|
657
693
|
subset=(df_orig.index, df_orig.columns) if total_exclude else None,
|
658
694
|
)
|
659
695
|
|
696
|
+
if png_path is not None:
|
697
|
+
# * 72dpi default is too low for high res displays
|
698
|
+
dfi.export(obj=out, filename=png_path, dpi=150, table_conversion=png_conversion)
|
699
|
+
|
660
700
|
return out
|
661
701
|
|
662
702
|
def print_summary(df: pd.DataFrame | pd.Series, name: str="🟠 "):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pandas-plots
|
3
|
-
Version: 0.11.
|
3
|
+
Version: 0.11.27
|
4
4
|
Summary: A collection of helper for table handling and visualization
|
5
5
|
Home-page: https://github.com/smeisegeier/pandas-plots
|
6
6
|
Author: smeisegeier
|
@@ -31,6 +31,7 @@ Requires-Dist: missingno>=0.5.2
|
|
31
31
|
Requires-Dist: duckdb>=1.0.0
|
32
32
|
Requires-Dist: kaleido>=0.2.0
|
33
33
|
Requires-Dist: nbformat>=4.2.0
|
34
|
+
Requires-Dist: dataframe_image>=0.2.6
|
34
35
|
|
35
36
|
# pandas-plots
|
36
37
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
pandas_plots/hlp.py,sha256=N6NrbFagVMMX-ZnV0rIBEz82SeSoOkksfMcCap55W7E,16588
|
2
|
+
pandas_plots/pii.py,sha256=2WKE-W9s285jPdsTqCgt1uxuW4lj1PYCVOYB2fYDNwQ,2195
|
3
|
+
pandas_plots/pls.py,sha256=U-tjh0DnYQYg-n02hh_HyvObMerkGCBP8tirKFIEEn4,37376
|
4
|
+
pandas_plots/tbl.py,sha256=kWe_H1hhJHOQR7SjTEUjRVCFxUW4VmH1EiuB2ZO0RWU,30241
|
5
|
+
pandas_plots/ven.py,sha256=2x3ACo2vSfO3q6fv-UdDQ0h1SJyt8WChBGgE5SDCdCk,11673
|
6
|
+
pandas_plots-0.11.27.dist-info/LICENSE,sha256=6KQ5KVAAhRaB-JJKpX4cefKvRZRgI7GUPc92_2d31XY,1051
|
7
|
+
pandas_plots-0.11.27.dist-info/METADATA,sha256=S8Z3xQSAoHi2ClBL_47UhWHQOtyultIp2TOm8iu9jFU,7258
|
8
|
+
pandas_plots-0.11.27.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
|
9
|
+
pandas_plots-0.11.27.dist-info/top_level.txt,sha256=XnaNuIHBqMmCeh_U7nKOYTwFue_SIA0wxuDgdPmnnSk,13
|
10
|
+
pandas_plots-0.11.27.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
pandas_plots/hlp.py,sha256=N6NrbFagVMMX-ZnV0rIBEz82SeSoOkksfMcCap55W7E,16588
|
2
|
-
pandas_plots/pii.py,sha256=2WKE-W9s285jPdsTqCgt1uxuW4lj1PYCVOYB2fYDNwQ,2195
|
3
|
-
pandas_plots/pls.py,sha256=U-tjh0DnYQYg-n02hh_HyvObMerkGCBP8tirKFIEEn4,37376
|
4
|
-
pandas_plots/tbl.py,sha256=A1SqvssDA4ofI_WJ-sdWIb9Bo5X-sELD8pley22Y4X4,28380
|
5
|
-
pandas_plots/ven.py,sha256=2x3ACo2vSfO3q6fv-UdDQ0h1SJyt8WChBGgE5SDCdCk,11673
|
6
|
-
pandas_plots-0.11.25.dist-info/LICENSE,sha256=6KQ5KVAAhRaB-JJKpX4cefKvRZRgI7GUPc92_2d31XY,1051
|
7
|
-
pandas_plots-0.11.25.dist-info/METADATA,sha256=ozN_fz1-7R1-lEMGUQD_XJ4qa3RBUsGdS0gXw7EGBrY,7220
|
8
|
-
pandas_plots-0.11.25.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
|
9
|
-
pandas_plots-0.11.25.dist-info/top_level.txt,sha256=XnaNuIHBqMmCeh_U7nKOYTwFue_SIA0wxuDgdPmnnSk,13
|
10
|
-
pandas_plots-0.11.25.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|