pandas-plots 0.12.17__tar.gz → 0.12.18__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,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pandas-plots
3
- Version: 0.12.17
3
+ Version: 0.12.18
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
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = pandas-plots
3
- version = 0.12.17
3
+ version = 0.12.18
4
4
  author = smeisegeier
5
5
  author_email = dexterDSDo@googlemail.com
6
6
  description = A collection of helper for table handling and visualization
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pandas-plots
3
- Version: 0.12.17
3
+ Version: 0.12.18
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
File without changes
File without changes