rgwfuncs 0.0.21__tar.gz → 0.0.22__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.
- {rgwfuncs-0.0.21/src/rgwfuncs.egg-info → rgwfuncs-0.0.22}/PKG-INFO +1 -1
- {rgwfuncs-0.0.21 → rgwfuncs-0.0.22}/pyproject.toml +1 -1
- {rgwfuncs-0.0.21 → rgwfuncs-0.0.22}/setup.cfg +1 -1
- {rgwfuncs-0.0.21 → rgwfuncs-0.0.22}/src/rgwfuncs/df_lib.py +22 -3
- {rgwfuncs-0.0.21 → rgwfuncs-0.0.22/src/rgwfuncs.egg-info}/PKG-INFO +1 -1
- {rgwfuncs-0.0.21 → rgwfuncs-0.0.22}/LICENSE +0 -0
- {rgwfuncs-0.0.21 → rgwfuncs-0.0.22}/README.md +0 -0
- {rgwfuncs-0.0.21 → rgwfuncs-0.0.22}/src/rgwfuncs/__init__.py +0 -0
- {rgwfuncs-0.0.21 → rgwfuncs-0.0.22}/src/rgwfuncs/str_lib.py +0 -0
- {rgwfuncs-0.0.21 → rgwfuncs-0.0.22}/src/rgwfuncs.egg-info/SOURCES.txt +0 -0
- {rgwfuncs-0.0.21 → rgwfuncs-0.0.22}/src/rgwfuncs.egg-info/dependency_links.txt +0 -0
- {rgwfuncs-0.0.21 → rgwfuncs-0.0.22}/src/rgwfuncs.egg-info/entry_points.txt +0 -0
- {rgwfuncs-0.0.21 → rgwfuncs-0.0.22}/src/rgwfuncs.egg-info/requires.txt +0 -0
- {rgwfuncs-0.0.21 → rgwfuncs-0.0.22}/src/rgwfuncs.egg-info/top_level.txt +0 -0
@@ -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,7 +1708,21 @@ def print_n_frequency_linear(df: pd.DataFrame, n: int, columns: list, order_by:
|
|
1709
1708
|
|
1710
1709
|
return report
|
1711
1710
|
|
1711
|
+
def can_convert_keys_to_int(keys):
|
1712
|
+
"""Helper function to check if all keys can be converted to integers."""
|
1713
|
+
try:
|
1714
|
+
[int(key) for key in keys]
|
1715
|
+
return True
|
1716
|
+
except ValueError:
|
1717
|
+
return False
|
1718
|
+
|
1712
1719
|
def sort_frequency(frequency, order_by):
|
1720
|
+
keys = frequency.keys()
|
1721
|
+
|
1722
|
+
# Determine if we can sort by integer values of keys
|
1723
|
+
if can_convert_keys_to_int(keys):
|
1724
|
+
keys = list(map(int, keys)) # Convert keys to integers, and keep original order
|
1725
|
+
|
1713
1726
|
if order_by == "ASC":
|
1714
1727
|
return dict(sorted(frequency.items(), key=lambda item: item[0]))
|
1715
1728
|
elif order_by == "DESC":
|
@@ -1721,9 +1734,15 @@ def print_n_frequency_linear(df: pd.DataFrame, n: int, columns: list, order_by:
|
|
1721
1734
|
elif order_by == "FREQ_ASC":
|
1722
1735
|
return dict(sorted(frequency.items(), key=lambda item: item[1]))
|
1723
1736
|
elif order_by == "BY_KEYS_ASC":
|
1724
|
-
|
1737
|
+
if isinstance(keys[0], int):
|
1738
|
+
return dict(sorted(frequency.items(), key=lambda item: int(item[0])))
|
1739
|
+
else:
|
1740
|
+
return dict(sorted(frequency.items()))
|
1725
1741
|
elif order_by == "BY_KEYS_DESC":
|
1726
|
-
|
1742
|
+
if isinstance(keys[0], int):
|
1743
|
+
return dict(sorted(frequency.items(), key=lambda item: int(item[0]), reverse=True))
|
1744
|
+
else:
|
1745
|
+
return dict(sorted(frequency.items(), reverse=True))
|
1727
1746
|
else: # Default to "FREQ_DESC"
|
1728
1747
|
return dict(
|
1729
1748
|
sorted(
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|