opsci-toolbox 0.0.10__py3-none-any.whl → 0.0.11__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.
- opsci_toolbox/helpers/common.py +39 -20
- opsci_toolbox/helpers/dataviz.py +4262 -1975
- opsci_toolbox/helpers/nlp.py +53 -32
- opsci_toolbox-0.0.11.dist-info/METADATA +53 -0
- {opsci_toolbox-0.0.10.dist-info → opsci_toolbox-0.0.11.dist-info}/RECORD +7 -7
- {opsci_toolbox-0.0.10.dist-info → opsci_toolbox-0.0.11.dist-info}/WHEEL +1 -1
- opsci_toolbox-0.0.10.dist-info/METADATA +0 -53
- {opsci_toolbox-0.0.10.dist-info → opsci_toolbox-0.0.11.dist-info}/top_level.txt +0 -0
opsci_toolbox/helpers/common.py
CHANGED
@@ -1219,25 +1219,6 @@ def top_rows_per_category(df: pd.DataFrame,
|
|
1219
1219
|
)[cols_to_keep]
|
1220
1220
|
return df_gb
|
1221
1221
|
|
1222
|
-
def format_number(number: int) -> str:
|
1223
|
-
"""
|
1224
|
-
Format a number into a human-readable string with K, M, or B suffixes.
|
1225
|
-
|
1226
|
-
Args:
|
1227
|
-
number (int): The number to format.
|
1228
|
-
|
1229
|
-
Returns:
|
1230
|
-
str: The formatted number as a string with an appropriate suffix.
|
1231
|
-
"""
|
1232
|
-
if number < 1000:
|
1233
|
-
return str(number)
|
1234
|
-
elif number < 1000000:
|
1235
|
-
return f"{number / 1000:.1f}K"
|
1236
|
-
elif number < 1000000000:
|
1237
|
-
return f"{number / 1000000:.1f}M"
|
1238
|
-
else:
|
1239
|
-
return f"{number / 1000000000:.1f}B"
|
1240
|
-
|
1241
1222
|
|
1242
1223
|
|
1243
1224
|
def unrar_file(rar_file_path : str, output_dir : str) -> None:
|
@@ -1330,4 +1311,42 @@ def remove_empty_folders(path: str):
|
|
1330
1311
|
# If the directory is empty, remove it
|
1331
1312
|
if not os.listdir(dir_path):
|
1332
1313
|
os.rmdir(dir_path)
|
1333
|
-
print(f"Removed empty folder: {dir_path}")
|
1314
|
+
print(f"Removed empty folder: {dir_path}")
|
1315
|
+
|
1316
|
+
|
1317
|
+
def categorize_percentiles(percentile: float) -> str:
|
1318
|
+
"""
|
1319
|
+
Categorizes a percentile value into a string representing its range.
|
1320
|
+
|
1321
|
+
Args:
|
1322
|
+
- percentile (float): The percentile value (between 0 and 1).
|
1323
|
+
|
1324
|
+
Returns:
|
1325
|
+
- str: The category of the percentile value.
|
1326
|
+
|
1327
|
+
Raises:
|
1328
|
+
- ValueError: If the percentile value is outside the range [0, 1].
|
1329
|
+
"""
|
1330
|
+
if not (0 <= percentile <= 1):
|
1331
|
+
raise ValueError("Percentile must be between 0 and 1 inclusive.")
|
1332
|
+
|
1333
|
+
if percentile <= 0.1:
|
1334
|
+
return '0-10%'
|
1335
|
+
elif percentile <= 0.2:
|
1336
|
+
return '10-20%'
|
1337
|
+
elif percentile <= 0.3:
|
1338
|
+
return '20-30%'
|
1339
|
+
elif percentile <= 0.4:
|
1340
|
+
return '30-40%'
|
1341
|
+
elif percentile <= 0.5:
|
1342
|
+
return '40-50%'
|
1343
|
+
elif percentile <= 0.6:
|
1344
|
+
return '50-60%'
|
1345
|
+
elif percentile <= 0.7:
|
1346
|
+
return '60-70%'
|
1347
|
+
elif percentile <= 0.8:
|
1348
|
+
return '70-80%'
|
1349
|
+
elif percentile <= 0.9:
|
1350
|
+
return '80-90%'
|
1351
|
+
else:
|
1352
|
+
return '90-100%'
|