pandas-plots 0.12.16__py3-none-any.whl → 0.12.18__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/hlp.py +30 -2
- pandas_plots/pls.py +16 -3
- pandas_plots/tbl.py +14 -0
- {pandas_plots-0.12.16.dist-info → pandas_plots-0.12.18.dist-info}/METADATA +1 -1
- pandas_plots-0.12.18.dist-info/RECORD +11 -0
- pandas_plots-0.12.16.dist-info/RECORD +0 -11
- {pandas_plots-0.12.16.dist-info → pandas_plots-0.12.18.dist-info}/LICENSE +0 -0
- {pandas_plots-0.12.16.dist-info → pandas_plots-0.12.18.dist-info}/WHEEL +0 -0
- {pandas_plots-0.12.16.dist-info → pandas_plots-0.12.18.dist-info}/pii.py +0 -0
- {pandas_plots-0.12.16.dist-info → pandas_plots-0.12.18.dist-info}/top_level.txt +0 -0
pandas_plots/hlp.py
CHANGED
@@ -471,7 +471,7 @@ pd.DataFrame.add_bitmask_label = add_bitmask_label
|
|
471
471
|
ddb.DuckDBPyRelation.add_bitmask_label = add_bitmask_label
|
472
472
|
|
473
473
|
|
474
|
-
def find_cols(all_cols: list[str], stubs
|
474
|
+
def find_cols(all_cols: list[str], stubs: list[str] = None):
|
475
475
|
"""
|
476
476
|
Find all columns in a list of columns that contain any of the given stubs.
|
477
477
|
|
@@ -487,10 +487,38 @@ def find_cols(all_cols: list[str], stubs=list[str]):
|
|
487
487
|
list[str]
|
488
488
|
List of columns that contain any of the given stubs.
|
489
489
|
"""
|
490
|
-
if all_cols is None or
|
490
|
+
if all_cols is None or stubs is None:
|
491
491
|
return "❌ empty lists"
|
492
492
|
return [col for col in all_cols if any(match in col for match in stubs)]
|
493
493
|
|
494
|
+
def find_cols(all_cols: list[str], stubs: list[str] = None) -> list[str]:
|
495
|
+
"""
|
496
|
+
Find all columns in a list of columns that contain any of the given stubs,
|
497
|
+
preserving the order of stubs in the output.
|
498
|
+
|
499
|
+
Parameters
|
500
|
+
----------
|
501
|
+
all_cols : list[str]
|
502
|
+
List of columns to search in.
|
503
|
+
stubs : list[str], optional
|
504
|
+
List of strings to search for in column names.
|
505
|
+
|
506
|
+
Returns
|
507
|
+
-------
|
508
|
+
list[str]
|
509
|
+
List of columns that contain any of the given stubs, ordered by stubs.
|
510
|
+
"""
|
511
|
+
if all_cols is None or not stubs:
|
512
|
+
print("❌ empty lists")
|
513
|
+
return []
|
514
|
+
|
515
|
+
result = []
|
516
|
+
for stub in stubs:
|
517
|
+
result.extend([col for col in all_cols if stub in col])
|
518
|
+
|
519
|
+
return result
|
520
|
+
|
521
|
+
|
494
522
|
# * extend objects to enable chaining
|
495
523
|
pd.DataFrame.find_cols = find_cols
|
496
524
|
|
pandas_plots/pls.py
CHANGED
@@ -661,7 +661,6 @@ def plot_bars(
|
|
661
661
|
|
662
662
|
# * layot caption if provided
|
663
663
|
caption = _set_caption(caption)
|
664
|
-
|
665
664
|
# ! plot
|
666
665
|
_fig = px.bar(
|
667
666
|
df.sort_values(
|
@@ -674,7 +673,7 @@ def plot_bars(
|
|
674
673
|
orientation=orientation,
|
675
674
|
# * retrieve the original columns from series
|
676
675
|
title=title
|
677
|
-
or f"{caption}{_title_str_minval}{_title_str_top}[{
|
676
|
+
or f"{caption}{_title_str_minval}{_title_str_top}[{col_name}] by [{col_index}]{_title_str_null}{_title_str_n}",
|
678
677
|
# * retrieve theme from env (intro.set_theme) or default
|
679
678
|
template="plotly_dark" if os.getenv("THEME") == "dark" else "plotly",
|
680
679
|
width=width,
|
@@ -732,8 +731,22 @@ def plot_bars(
|
|
732
731
|
|
733
732
|
# * looks better on single bars
|
734
733
|
_fig.update_traces(
|
735
|
-
|
734
|
+
error_y=dict(thickness=5)
|
736
735
|
)
|
736
|
+
if use_ci:
|
737
|
+
_fig.update_traces(
|
738
|
+
textposition="inside", # Put labels inside bars
|
739
|
+
insidetextanchor="start", # Align labels at the bottom
|
740
|
+
textfont=dict(size=14, color="white") # Adjust text color for visibility
|
741
|
+
)
|
742
|
+
else:
|
743
|
+
_fig.update_traces(
|
744
|
+
textposition="outside",
|
745
|
+
# error_y=dict(thickness=0)
|
746
|
+
)
|
747
|
+
|
748
|
+
# * set axis title
|
749
|
+
|
737
750
|
_fig.show(renderer)
|
738
751
|
|
739
752
|
# * save to png if path is provided
|
pandas_plots/tbl.py
CHANGED
@@ -269,6 +269,7 @@ def pivot_df(
|
|
269
269
|
alter_font: bool = True,
|
270
270
|
font_size_th: int = 0,
|
271
271
|
font_size_td: int = 0,
|
272
|
+
col1_width: int = 0,
|
272
273
|
png_path: str | Path = None,
|
273
274
|
png_conversion: Literal["chrome", "selenium"] = "selenium",
|
274
275
|
) -> pd.DataFrame:
|
@@ -306,6 +307,7 @@ def pivot_df(
|
|
306
307
|
alter_font (bool, optional): Whether to alter the font. Defaults to True.
|
307
308
|
font_size_th (int, optional): The font size for the header. Defaults to 0.
|
308
309
|
font_size_td (int, optional): The font size for the table data. Defaults to 0.
|
310
|
+
col1_width (int, optional): The width of the first column in px. Defaults to 0.
|
309
311
|
png_path (str | Path, optional): The path to save the output PNG file. Defaults to None.
|
310
312
|
png_conversion (Literal["chrome", "selenium"], optional): The conversion method for the PNG file. Defaults to "selenium".
|
311
313
|
|
@@ -393,6 +395,7 @@ def pivot_df(
|
|
393
395
|
alter_font=alter_font,
|
394
396
|
font_size_th=font_size_th,
|
395
397
|
font_size_td=font_size_td,
|
398
|
+
col1_width=col1_width,
|
396
399
|
png_path=png_path,
|
397
400
|
png_conversion=png_conversion,
|
398
401
|
|
@@ -416,6 +419,7 @@ def show_num_df(
|
|
416
419
|
alter_font: bool = True,
|
417
420
|
font_size_th: int = 0,
|
418
421
|
font_size_td: int = 0,
|
422
|
+
col1_width: int = 0,
|
419
423
|
png_path: str | Path = None,
|
420
424
|
png_conversion: Literal["chrome", "selenium"] = "selenium",
|
421
425
|
):
|
@@ -445,6 +449,7 @@ def show_num_df(
|
|
445
449
|
- alter_font: a boolean indicating whether to alter the font family
|
446
450
|
- font_size_th: an integer indicating the font size for the header
|
447
451
|
- font_size_td: an integer indicating the font size for the table data
|
452
|
+
- col1_width: an integer indicating the width of the first column in px
|
448
453
|
- png_path: a string or Path indicating the path to save the PNG file
|
449
454
|
- png_conversion: a Literal indicating the conversion method for the PNG file ["chrome", "selenium"]
|
450
455
|
|
@@ -680,6 +685,15 @@ def show_num_df(
|
|
680
685
|
dict(selector="td", props=_props_td),
|
681
686
|
]
|
682
687
|
)
|
688
|
+
|
689
|
+
if col1_width > 0:
|
690
|
+
out.set_table_styles([
|
691
|
+
{'selector': 'th:first-child, td:first-child',
|
692
|
+
'props': [(f'min-width', f'{col1_width}px !important'),
|
693
|
+
(f'max-width', f'{col1_width}px !important'),
|
694
|
+
('white-space', 'nowrap'),
|
695
|
+
('overflow', 'hidden')]}
|
696
|
+
])
|
683
697
|
|
684
698
|
if heatmap_axis:
|
685
699
|
out.background_gradient(
|
@@ -0,0 +1,11 @@
|
|
1
|
+
pandas_plots/hlp.py,sha256=hlz7kKe6iDsz6Ov5YadX9zT5E01DHy7gHdVPgG8P7nQ,19656
|
2
|
+
pandas_plots/pii.py,sha256=2WKE-W9s285jPdsTqCgt1uxuW4lj1PYCVOYB2fYDNwQ,2195
|
3
|
+
pandas_plots/pls.py,sha256=YbWPk34oJ3SJ-n7O-FvMOYR2FT2uNbMe93E0dbVTetk,48170
|
4
|
+
pandas_plots/tbl.py,sha256=LxMKJh4qkGuQZ1DdCZIq1tMS26F6elsqbe_uabvQx4E,32535
|
5
|
+
pandas_plots/ven.py,sha256=2x3ACo2vSfO3q6fv-UdDQ0h1SJyt8WChBGgE5SDCdCk,11673
|
6
|
+
pandas_plots-0.12.18.dist-info/LICENSE,sha256=6KQ5KVAAhRaB-JJKpX4cefKvRZRgI7GUPc92_2d31XY,1051
|
7
|
+
pandas_plots-0.12.18.dist-info/METADATA,sha256=0JzJDbgvUgQAIsn3X3bj4B1ZVaU2L1U0SegY2OVgEH8,7550
|
8
|
+
pandas_plots-0.12.18.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
9
|
+
pandas_plots-0.12.18.dist-info/pii.py,sha256=2WKE-W9s285jPdsTqCgt1uxuW4lj1PYCVOYB2fYDNwQ,2195
|
10
|
+
pandas_plots-0.12.18.dist-info/top_level.txt,sha256=XnaNuIHBqMmCeh_U7nKOYTwFue_SIA0wxuDgdPmnnSk,13
|
11
|
+
pandas_plots-0.12.18.dist-info/RECORD,,
|
@@ -1,11 +0,0 @@
|
|
1
|
-
pandas_plots/hlp.py,sha256=ggIe9uwF4tlVWqaBxQOkn8Dz8955xjY-TYG-lzypWFE,18905
|
2
|
-
pandas_plots/pii.py,sha256=2WKE-W9s285jPdsTqCgt1uxuW4lj1PYCVOYB2fYDNwQ,2195
|
3
|
-
pandas_plots/pls.py,sha256=OLaX5gWbsuYniikpojqPxZt9oQK_PI1XyJEQkbNlSk8,47809
|
4
|
-
pandas_plots/tbl.py,sha256=VNhb-3Vezl4imIS5omzHFd9rsEYFwq2YIx-DFVtiOSc,31930
|
5
|
-
pandas_plots/ven.py,sha256=2x3ACo2vSfO3q6fv-UdDQ0h1SJyt8WChBGgE5SDCdCk,11673
|
6
|
-
pandas_plots-0.12.16.dist-info/LICENSE,sha256=6KQ5KVAAhRaB-JJKpX4cefKvRZRgI7GUPc92_2d31XY,1051
|
7
|
-
pandas_plots-0.12.16.dist-info/METADATA,sha256=rLLfHJM27ITmbsVzso-HKiEaPflY-pTpAt31xiORPWA,7550
|
8
|
-
pandas_plots-0.12.16.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
9
|
-
pandas_plots-0.12.16.dist-info/pii.py,sha256=2WKE-W9s285jPdsTqCgt1uxuW4lj1PYCVOYB2fYDNwQ,2195
|
10
|
-
pandas_plots-0.12.16.dist-info/top_level.txt,sha256=XnaNuIHBqMmCeh_U7nKOYTwFue_SIA0wxuDgdPmnnSk,13
|
11
|
-
pandas_plots-0.12.16.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|