dragon-ml-toolbox 10.4.1__tar.gz → 10.5.0__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.
Potentially problematic release.
This version of dragon-ml-toolbox might be problematic. Click here for more details.
- {dragon_ml_toolbox-10.4.1/dragon_ml_toolbox.egg-info → dragon_ml_toolbox-10.5.0}/PKG-INFO +1 -1
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0/dragon_ml_toolbox.egg-info}/PKG-INFO +1 -1
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/ETL_engineering.py +5 -1
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/data_exploration.py +37 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/pyproject.toml +1 -1
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/LICENSE +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/LICENSE-THIRD-PARTY.md +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/README.md +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/dragon_ml_toolbox.egg-info/SOURCES.txt +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/dragon_ml_toolbox.egg-info/dependency_links.txt +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/dragon_ml_toolbox.egg-info/requires.txt +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/dragon_ml_toolbox.egg-info/top_level.txt +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/ETL_cleaning.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/GUI_tools.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/MICE_imputation.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/ML_callbacks.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/ML_datasetmaster.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/ML_evaluation.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/ML_evaluation_multi.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/ML_inference.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/ML_models.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/ML_optimization.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/ML_scaler.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/ML_trainer.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/PSO_optimization.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/RNN_forecast.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/SQL.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/VIF_factor.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/__init__.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/_logger.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/_script_info.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/custom_logger.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/ensemble_evaluation.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/ensemble_inference.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/ensemble_learning.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/handle_excel.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/keys.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/optimization_tools.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/path_manager.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/ml_tools/utilities.py +0 -0
- {dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/setup.cfg +0 -0
|
@@ -714,7 +714,11 @@ class TemperatureExtractor:
|
|
|
714
714
|
if self.average_mode:
|
|
715
715
|
# Extract all numbers and compute their mean. Polars' list.mean()
|
|
716
716
|
# handles the casting to float automatically.
|
|
717
|
-
celsius_expr =
|
|
717
|
+
celsius_expr = (
|
|
718
|
+
column.str.extract_all(self._avg_mode_pattern)
|
|
719
|
+
.list.eval(pl.element().cast(pl.Float64, strict=False))
|
|
720
|
+
.list.mean()
|
|
721
|
+
)
|
|
718
722
|
else:
|
|
719
723
|
# Extract a single number using the specified pattern.
|
|
720
724
|
# Cast to Float64, with non-matches becoming null.
|
|
@@ -21,6 +21,7 @@ __all__ = [
|
|
|
21
21
|
"show_null_columns",
|
|
22
22
|
"drop_columns_with_missing_data",
|
|
23
23
|
"drop_macro",
|
|
24
|
+
"clean_column_names",
|
|
24
25
|
"split_features_targets",
|
|
25
26
|
"split_continuous_binary",
|
|
26
27
|
"plot_correlation_heatmap",
|
|
@@ -300,6 +301,42 @@ def drop_macro(df: pd.DataFrame,
|
|
|
300
301
|
return df_clean
|
|
301
302
|
|
|
302
303
|
|
|
304
|
+
def clean_column_names(df: pd.DataFrame, replacement_char: str = '-', replacement_pattern: str = r'[\[\]{}<>,:"]', verbose: bool = True) -> pd.DataFrame:
|
|
305
|
+
"""
|
|
306
|
+
Cleans DataFrame column names by replacing special characters.
|
|
307
|
+
|
|
308
|
+
This function is useful for ensuring compatibility with libraries like LightGBM,
|
|
309
|
+
which do not support special JSON characters such as `[]{}<>,:"` in feature names.
|
|
310
|
+
|
|
311
|
+
Args:
|
|
312
|
+
df (pd.DataFrame): The input DataFrame.
|
|
313
|
+
replacement_char (str): The character to use for replacing characters.
|
|
314
|
+
replacement_pattern (str): Regex pattern to use for the replacement logic.
|
|
315
|
+
verbose (bool): If True, prints the renamed columns.
|
|
316
|
+
|
|
317
|
+
Returns:
|
|
318
|
+
pd.DataFrame: A new DataFrame with cleaned column names.
|
|
319
|
+
"""
|
|
320
|
+
new_df = df.copy()
|
|
321
|
+
|
|
322
|
+
original_columns = new_df.columns
|
|
323
|
+
new_columns = original_columns.str.replace(replacement_pattern, replacement_char, regex=True)
|
|
324
|
+
|
|
325
|
+
# Create a map of changes for logging
|
|
326
|
+
rename_map = {old: new for old, new in zip(original_columns, new_columns) if old != new}
|
|
327
|
+
|
|
328
|
+
if verbose:
|
|
329
|
+
if rename_map:
|
|
330
|
+
_LOGGER.info(f"Cleaned {len(rename_map)} column name(s) containing special characters:")
|
|
331
|
+
for old, new in rename_map.items():
|
|
332
|
+
print(f" '{old}' -> '{new}'")
|
|
333
|
+
else:
|
|
334
|
+
_LOGGER.info("No column names required cleaning.")
|
|
335
|
+
|
|
336
|
+
new_df.columns = new_columns
|
|
337
|
+
return new_df
|
|
338
|
+
|
|
339
|
+
|
|
303
340
|
def split_features_targets(df: pd.DataFrame, targets: list[str]):
|
|
304
341
|
"""
|
|
305
342
|
Splits a DataFrame's columns into features and targets.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/dragon_ml_toolbox.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/dragon_ml_toolbox.egg-info/requires.txt
RENAMED
|
File without changes
|
{dragon_ml_toolbox-10.4.1 → dragon_ml_toolbox-10.5.0}/dragon_ml_toolbox.egg-info/top_level.txt
RENAMED
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|