pandas-plots 0.12.17__tar.gz → 0.12.19__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.
@@ -1,11 +1,11 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: pandas-plots
3
- Version: 0.12.17
3
+ Version: 0.12.19
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
7
7
  Author-email: dexterDSDo@googlemail.com
8
- License: MIT License
8
+ License: "MIT"
9
9
  Project-URL: Documentation, https://github.com/smeisegeier/pandas-plots
10
10
  Project-URL: Source Code, https://github.com/smeisegeier/pandas-plots
11
11
  Project-URL: Bug Tracker, https://github.com/smeisegeier/pandas-plots/issues
@@ -32,6 +32,7 @@ Requires-Dist: duckdb>=1.0.0
32
32
  Requires-Dist: kaleido>=0.2.0
33
33
  Requires-Dist: nbformat>=4.2.0
34
34
  Requires-Dist: dataframe_image>=0.2.6
35
+ Dynamic: license-file
35
36
 
36
37
  # pandas-plots
37
38
 
@@ -1,12 +1,12 @@
1
1
  [metadata]
2
2
  name = pandas-plots
3
- version = 0.12.17
3
+ version = 0.12.19
4
4
  author = smeisegeier
5
5
  author_email = dexterDSDo@googlemail.com
6
6
  description = A collection of helper for table handling and visualization
7
7
  long_description = file: README.md
8
8
  long_description_content_type = text/markdown
9
- license = MIT License
9
+ license = "MIT"
10
10
  license_files = LICENSE
11
11
  url = https://github.com/smeisegeier/pandas-plots
12
12
  project_urls =
@@ -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=list[str]):
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 not stubs:
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
 
@@ -340,7 +340,7 @@ def plot_stacked_bars(
340
340
  _title_str_top_index = f"TOP{top_n_index} " if top_n_index > 0 else ""
341
341
  _title_str_top_color = f"TOP{top_n_color} " if top_n_color > 0 else ""
342
342
  _title_str_null = f", NULL excluded" if dropna else ""
343
- _title_str_n = f", n={n:_}"
343
+ _title_str_n = f", n={len(df):_} ({n:_})"
344
344
 
345
345
  _df = df.copy().assign(facet=None)
346
346
  _df.columns = (
@@ -653,7 +653,7 @@ def plot_bars(
653
653
 
654
654
  # * title str n
655
655
  _title_str_n = (
656
- f", n={n:_}" if not use_ci else f", n={n_len:_}<br><sub>ci(95) on means<sub>"
656
+ f", n={n_len:_} ({n:_})" if not use_ci else f", n={n_len:_})<br><sub>ci(95) on means<sub>"
657
657
  )
658
658
 
659
659
  # * title str na
@@ -1325,6 +1325,8 @@ def plot_facet_stacked_bars(
1325
1325
  df["value"] = 1
1326
1326
  elif df.shape[1] == 4:
1327
1327
  df.columns = ["index", "col", "facet", "value"]
1328
+
1329
+ n = df["value"].sum()
1328
1330
 
1329
1331
  aggregated_df = aggregate_data(
1330
1332
  df,
@@ -1427,7 +1429,7 @@ def plot_facet_stacked_bars(
1427
1429
  else:
1428
1430
  axis_details.append(f"[{original_column_names[2]}]")
1429
1431
 
1430
- title = f"{caption} {', '.join(axis_details)}, n = {original_rows:_}"
1432
+ title = f"{caption} {', '.join(axis_details)}, n = {original_rows:_} ({n:_})"
1431
1433
  template = "plotly_dark" if os.getenv("THEME") == "dark" else "plotly"
1432
1434
 
1433
1435
  fig.update_layout(
@@ -1,11 +1,11 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: pandas-plots
3
- Version: 0.12.17
3
+ Version: 0.12.19
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
7
7
  Author-email: dexterDSDo@googlemail.com
8
- License: MIT License
8
+ License: "MIT"
9
9
  Project-URL: Documentation, https://github.com/smeisegeier/pandas-plots
10
10
  Project-URL: Source Code, https://github.com/smeisegeier/pandas-plots
11
11
  Project-URL: Bug Tracker, https://github.com/smeisegeier/pandas-plots/issues
@@ -32,6 +32,7 @@ Requires-Dist: duckdb>=1.0.0
32
32
  Requires-Dist: kaleido>=0.2.0
33
33
  Requires-Dist: nbformat>=4.2.0
34
34
  Requires-Dist: dataframe_image>=0.2.6
35
+ Dynamic: license-file
35
36
 
36
37
  # pandas-plots
37
38
 
File without changes
File without changes