pandas-plots 0.11.0__py3-none-any.whl → 0.11.1__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 +22 -0
- pandas_plots/pls.py +1 -1
- pandas_plots/tbl.py +11 -8
- pandas_plots/ven.py +0 -1
- {pandas_plots-0.11.0.dist-info → pandas_plots-0.11.1.dist-info}/METADATA +5 -4
- pandas_plots-0.11.1.dist-info/RECORD +9 -0
- {pandas_plots-0.11.0.dist-info → pandas_plots-0.11.1.dist-info}/WHEEL +1 -1
- pandas_plots-0.11.0.dist-info/RECORD +0 -9
- {pandas_plots-0.11.0.dist-info → pandas_plots-0.11.1.dist-info}/LICENSE +0 -0
- {pandas_plots-0.11.0.dist-info → pandas_plots-0.11.1.dist-info}/top_level.txt +0 -0
pandas_plots/hlp.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import pandas as pd
|
2
2
|
import numpy as np
|
3
3
|
import scipy.stats
|
4
|
+
import importlib.metadata as md
|
4
5
|
|
5
6
|
from io import BytesIO
|
6
7
|
from matplotlib import pyplot as plt
|
@@ -261,3 +262,24 @@ def add_datetime_columns(df: pd.DataFrame, date_column: str = None) -> pd.DataFr
|
|
261
262
|
)
|
262
263
|
|
263
264
|
return df_
|
265
|
+
|
266
|
+
|
267
|
+
def show_package_version(packages: list[str] = ["pandas","numpy","duckdb","pandas-plots", "connection_helper"], sep: str = " | ") -> None:
|
268
|
+
"""
|
269
|
+
Display the versions of the specified packages.
|
270
|
+
|
271
|
+
Parameters:
|
272
|
+
packages (list[str], optional): A list of package names. Defaults to ["pandas","numpy","duckdb","pandas-plots", "connection_helper"].
|
273
|
+
sep (str, optional): The separator to use when joining the package names and versions. Defaults to " | ".
|
274
|
+
|
275
|
+
Returns:
|
276
|
+
None
|
277
|
+
"""
|
278
|
+
items = []
|
279
|
+
for item in packages:
|
280
|
+
try:
|
281
|
+
version = md.version(item)
|
282
|
+
items.append(f"📦 {item}: {version}")
|
283
|
+
except md.PackageNotFoundError:
|
284
|
+
items.append(f"❌ {item}: Package not found")
|
285
|
+
print(sep.join(items))
|
pandas_plots/pls.py
CHANGED
@@ -125,7 +125,7 @@ def plot_stacked_bars(
|
|
125
125
|
Parameters:
|
126
126
|
- df: pd.DataFrame - The DataFrame containing the data to plot.
|
127
127
|
- top_n_index: int = 0 - The number of top indexes to include in the plot.
|
128
|
-
-
|
128
|
+
- top_n_color: int = 0 - The number of top colors to include in the plot. WARNING: this forces distribution to 100% on a subset
|
129
129
|
- dropna: bool = False - Whether to include NULL values in the plot.
|
130
130
|
- swap: bool = False - Whether to swap the x-axis and y-axis.
|
131
131
|
- normalize: bool = False - Whether to normalize the values.
|
pandas_plots/tbl.py
CHANGED
@@ -17,6 +17,7 @@ from scipy import stats
|
|
17
17
|
from .hlp import wrap_text
|
18
18
|
|
19
19
|
# from devtools import debug
|
20
|
+
|
20
21
|
pd.options.display.colheader_justify = "right"
|
21
22
|
# pd.options.mode.chained_assignment = None
|
22
23
|
|
@@ -225,6 +226,7 @@ def pivot_df(
|
|
225
226
|
kpi_shape: Literal["squad", "circle"] = "squad",
|
226
227
|
) -> pd.DataFrame:
|
227
228
|
"""
|
229
|
+
DEPR: This function is deprecated and will be removed in the future.
|
228
230
|
A function to pivot a DataFrame based on specified parameters and return the result as a new DataFrame.
|
229
231
|
|
230
232
|
Args:
|
@@ -365,6 +367,7 @@ def show_num_df(
|
|
365
367
|
- max_min_x: max value green, min valued red for x axis
|
366
368
|
- kpi_rag_list: a list of floats indicating the thresholds for rag lights. The list should have 2 elements.
|
367
369
|
- kpi_shape: a Literal indicating the shape of the KPIs ["squad", "circle"]
|
370
|
+
- show_as_pct: a boolean indicating whether to show value as percentage (only advised on values ~1)
|
368
371
|
|
369
372
|
The function returns a styled representation of the DataFrame.
|
370
373
|
"""
|
@@ -472,8 +475,13 @@ def show_num_df(
|
|
472
475
|
Returns:
|
473
476
|
str: The appropriate icon based on the value and KPI mode.
|
474
477
|
"""
|
478
|
+
|
479
|
+
# * no icon if no mode. (or Total column, but total index cannot be located)
|
475
480
|
if not kpi_mode:
|
481
|
+
# if not kpi_mode or col == "Total":
|
476
482
|
return ""
|
483
|
+
|
484
|
+
|
477
485
|
|
478
486
|
dict_icons = {
|
479
487
|
"squad": {
|
@@ -486,7 +494,6 @@ def show_num_df(
|
|
486
494
|
},
|
487
495
|
}
|
488
496
|
icons = dict_icons[kpi_shape][theme]
|
489
|
-
|
490
497
|
# * transform values into percentiles if relative mode
|
491
498
|
kpi_rag_list_ = kpi_rag_list
|
492
499
|
if kpi_mode == "rag_rel":
|
@@ -517,19 +524,14 @@ def show_num_df(
|
|
517
524
|
min_ = tbl_min if kpi_mode.endswith("_xy") else col_min[col]
|
518
525
|
max_ = tbl_max if kpi_mode.endswith("_xy") else col_max[col]
|
519
526
|
|
520
|
-
# * omit Total column for min/max
|
521
|
-
if col == "Total":
|
522
|
-
return ""
|
523
|
-
|
524
527
|
# * calculate order of icons
|
525
528
|
if kpi_mode.startswith("min_max"):
|
526
529
|
result = icons[0] if val == min_ else icons[2] if val == max_ else icons[3]
|
527
530
|
elif kpi_mode.startswith("max_min"):
|
528
531
|
result = icons[0] if val == max_ else icons[2] if val == min_ else icons[3]
|
529
532
|
else:
|
530
|
-
# * no matching mode
|
533
|
+
# * no matching mode found
|
531
534
|
result = ""
|
532
|
-
|
533
535
|
return result
|
534
536
|
|
535
537
|
# * all cell formatting in one place
|
@@ -562,7 +564,7 @@ def show_num_df(
|
|
562
564
|
return f"{val:.{precision}%} {kpi}"
|
563
565
|
return f"{val:_.{precision}f} {kpi}"
|
564
566
|
|
565
|
-
# * formatter is
|
567
|
+
# * formatter is a dict comprehension, only accepts column names
|
566
568
|
formatter = {col: lambda x, col=col: format_cell(x, col=col) for col in df_.columns}
|
567
569
|
|
568
570
|
# ? pct_axis y is not implemented, needs row wise formatting
|
@@ -572,6 +574,7 @@ def show_num_df(
|
|
572
574
|
# }
|
573
575
|
|
574
576
|
# * apply formatter
|
577
|
+
# debug(formatter)
|
575
578
|
out.format(formatter=formatter)
|
576
579
|
|
577
580
|
# * apply fonts for cells
|
pandas_plots/ven.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pandas-plots
|
3
|
-
Version: 0.11.
|
3
|
+
Version: 0.11.1
|
4
4
|
Summary: A collection of helper for table handling and vizualization
|
5
5
|
Home-page: https://github.com/smeisegeier/pandas-plots
|
6
6
|
Author: smeisegeier
|
@@ -29,7 +29,7 @@ Requires-Dist: requests >=2.31.0
|
|
29
29
|
|
30
30
|
# pandas-plots
|
31
31
|
|
32
|
-
      
|
33
33
|
|
34
34
|
## usage
|
35
35
|
|
@@ -98,8 +98,9 @@ tbl.show_num_df(
|
|
98
98
|
- `mean_confidence_interval()` calculates mean and confidence interval for a series
|
99
99
|
- `wrap_text()` formats strings or lists to a given width to fit nicely on the screen
|
100
100
|
- `replace_delimiter_outside_quotes()` when manual import of csv files is needed: replaces delimiters only outside of quotes
|
101
|
-
-
|
102
|
-
-
|
101
|
+
- `create_barcode_from_url()` creates a barcode from a given URL
|
102
|
+
- `add_datetime_col()` adds a datetime columns to a dataframe
|
103
|
+
- 🆕 `show_package_version` prints version of a list of packages
|
103
104
|
|
104
105
|
> note: theme setting can be controlled through all functions by setting the environment variable `THEME` to either light or dark
|
105
106
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
pandas_plots/hlp.py,sha256=polax8sI3z4fKXzIjmjIvDmgnIs3xpBLf4__HPdW9CM,10069
|
2
|
+
pandas_plots/pls.py,sha256=BzZge7TnECjCs47MZ7P63_y2WU23P9sLaMl7SKB5h1Q,35043
|
3
|
+
pandas_plots/tbl.py,sha256=IhDjn-ZD63af6R9WXLSaVGRXA35YM8BDj3OR_SIjG2M,23360
|
4
|
+
pandas_plots/ven.py,sha256=2x3ACo2vSfO3q6fv-UdDQ0h1SJyt8WChBGgE5SDCdCk,11673
|
5
|
+
pandas_plots-0.11.1.dist-info/LICENSE,sha256=6KQ5KVAAhRaB-JJKpX4cefKvRZRgI7GUPc92_2d31XY,1051
|
6
|
+
pandas_plots-0.11.1.dist-info/METADATA,sha256=LFXFik6-kCkSOiWspbRrQ9m4TXf2f0yFGGoJRclGLJE,6703
|
7
|
+
pandas_plots-0.11.1.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
|
8
|
+
pandas_plots-0.11.1.dist-info/top_level.txt,sha256=XnaNuIHBqMmCeh_U7nKOYTwFue_SIA0wxuDgdPmnnSk,13
|
9
|
+
pandas_plots-0.11.1.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
pandas_plots/hlp.py,sha256=sv0cRy_orkGnv3H6yQiaOIZ771cfA2aR-mz2upMC50A,9257
|
2
|
-
pandas_plots/pls.py,sha256=9nztIx9Nzec092KsBXSg7EEIyQnqNS5cUhdD7NgjkMg,35043
|
3
|
-
pandas_plots/tbl.py,sha256=Z7LraRWoFkLIKgI92-SV1Txs42uMwVsnSitZ57hr7h4,23078
|
4
|
-
pandas_plots/ven.py,sha256=nDKS7cTIHOJhIXKnAxAkEoqPgVZCUPJld5CvSiB2JC4,11721
|
5
|
-
pandas_plots-0.11.0.dist-info/LICENSE,sha256=6KQ5KVAAhRaB-JJKpX4cefKvRZRgI7GUPc92_2d31XY,1051
|
6
|
-
pandas_plots-0.11.0.dist-info/METADATA,sha256=5g7Jr_uVDt2QCidgNL6JgnqfJFYWsviv-Si6CJZFf-4,6630
|
7
|
-
pandas_plots-0.11.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
8
|
-
pandas_plots-0.11.0.dist-info/top_level.txt,sha256=XnaNuIHBqMmCeh_U7nKOYTwFue_SIA0wxuDgdPmnnSk,13
|
9
|
-
pandas_plots-0.11.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|