rgwfuncs 0.0.21__py3-none-any.whl → 0.0.23__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.
- rgwfuncs/df_lib.py +29 -21
- {rgwfuncs-0.0.21.dist-info → rgwfuncs-0.0.23.dist-info}/METADATA +1 -1
- rgwfuncs-0.0.23.dist-info/RECORD +9 -0
- rgwfuncs-0.0.21.dist-info/RECORD +0 -9
- {rgwfuncs-0.0.21.dist-info → rgwfuncs-0.0.23.dist-info}/LICENSE +0 -0
- {rgwfuncs-0.0.21.dist-info → rgwfuncs-0.0.23.dist-info}/WHEEL +0 -0
- {rgwfuncs-0.0.21.dist-info → rgwfuncs-0.0.23.dist-info}/entry_points.txt +0 -0
- {rgwfuncs-0.0.21.dist-info → rgwfuncs-0.0.23.dist-info}/top_level.txt +0 -0
rgwfuncs/df_lib.py
CHANGED
@@ -1672,7 +1672,6 @@ def print_n_frequency_cascading(
|
|
1672
1672
|
report = generate_cascade_report(df, columns, n, order_by)
|
1673
1673
|
print(json.dumps(report, indent=2))
|
1674
1674
|
|
1675
|
-
|
1676
1675
|
def print_n_frequency_linear(df: pd.DataFrame, n: int, columns: list, order_by: str = "FREQ_DESC") -> None:
|
1677
1676
|
"""
|
1678
1677
|
Print the linear frequency of top n values for specified columns.
|
@@ -1709,27 +1708,36 @@ def print_n_frequency_linear(df: pd.DataFrame, n: int, columns: list, order_by:
|
|
1709
1708
|
|
1710
1709
|
return report
|
1711
1710
|
|
1711
|
+
def try_parse_numeric(val):
|
1712
|
+
"""Attempt to parse a value as an integer or float."""
|
1713
|
+
try:
|
1714
|
+
return int(val)
|
1715
|
+
except ValueError:
|
1716
|
+
try:
|
1717
|
+
return float(val)
|
1718
|
+
except ValueError:
|
1719
|
+
return val
|
1720
|
+
|
1712
1721
|
def sort_frequency(frequency, order_by):
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
sorted(
|
1730
|
-
|
1731
|
-
|
1732
|
-
reverse=True))
|
1722
|
+
keys = frequency.keys()
|
1723
|
+
|
1724
|
+
# Convert keys to numerical values where possible, leaving `NaN` as a special string
|
1725
|
+
parsed_keys = [(try_parse_numeric(key), key) for key in keys]
|
1726
|
+
|
1727
|
+
if order_by in {"BY_KEYS_ASC", "BY_KEYS_DESC"}:
|
1728
|
+
reverse = order_by == "BY_KEYS_DESC"
|
1729
|
+
sorted_items = sorted(frequency.items(), key=lambda item: try_parse_numeric(item[0]), reverse=reverse)
|
1730
|
+
else:
|
1731
|
+
if order_by == "ASC":
|
1732
|
+
sorted_items = sorted(frequency.items(), key=lambda item: item[0])
|
1733
|
+
elif order_by == "DESC":
|
1734
|
+
sorted_items = sorted(frequency.items(), key=lambda item: item[0], reverse=True)
|
1735
|
+
elif order_by == "FREQ_ASC":
|
1736
|
+
sorted_items = sorted(frequency.items(), key=lambda item: item[1])
|
1737
|
+
else: # Default to "FREQ_DESC"
|
1738
|
+
sorted_items = sorted(frequency.items(), key=lambda item: item[1], reverse=True)
|
1739
|
+
|
1740
|
+
return dict(sorted_items)
|
1733
1741
|
|
1734
1742
|
report = generate_linear_report(df, columns, n, order_by)
|
1735
1743
|
print(json.dumps(report, indent=2))
|
@@ -0,0 +1,9 @@
|
|
1
|
+
rgwfuncs/__init__.py,sha256=2nrp3c5VmVrKh0Ih6zELL8niH9nAHN0XnObqe-EpxlE,1169
|
2
|
+
rgwfuncs/df_lib.py,sha256=8KMn4FucI19EFBHUoGOS7R4mo0degg6A6802sjy7BH4,67677
|
3
|
+
rgwfuncs/str_lib.py,sha256=I5B0WOGaLUGaedMG7hqiKnIqV7Jc9h1RYlgOiC_-iGY,3678
|
4
|
+
rgwfuncs-0.0.23.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
|
5
|
+
rgwfuncs-0.0.23.dist-info/METADATA,sha256=_mVsZMv4umMXMW_Q2hBxABMm75pKuvJgMIMBldXxCtk,34680
|
6
|
+
rgwfuncs-0.0.23.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
7
|
+
rgwfuncs-0.0.23.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
|
8
|
+
rgwfuncs-0.0.23.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
|
9
|
+
rgwfuncs-0.0.23.dist-info/RECORD,,
|
rgwfuncs-0.0.21.dist-info/RECORD
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
rgwfuncs/__init__.py,sha256=2nrp3c5VmVrKh0Ih6zELL8niH9nAHN0XnObqe-EpxlE,1169
|
2
|
-
rgwfuncs/df_lib.py,sha256=URN-ChKH7JUGcKeLVURGf5RrZS8psCWs5w7dkbtKmCk,67252
|
3
|
-
rgwfuncs/str_lib.py,sha256=I5B0WOGaLUGaedMG7hqiKnIqV7Jc9h1RYlgOiC_-iGY,3678
|
4
|
-
rgwfuncs-0.0.21.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
|
5
|
-
rgwfuncs-0.0.21.dist-info/METADATA,sha256=P0BVo_B-RPIjFzEGApdjjBTNuyE3wtiKgjhcrB35yPE,34680
|
6
|
-
rgwfuncs-0.0.21.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
7
|
-
rgwfuncs-0.0.21.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
|
8
|
-
rgwfuncs-0.0.21.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
|
9
|
-
rgwfuncs-0.0.21.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|