From 968814249a055c096acd6924edb5ce8f4c45bf2b Mon Sep 17 00:00:00 2001 From: JasonGellis Date: Wed, 4 Sep 2024 15:00:06 +0100 Subject: [PATCH] update mutable default argument --- cli/read_and_process.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cli/read_and_process.py b/cli/read_and_process.py index 24c4ca6..cd582b0 100644 --- a/cli/read_and_process.py +++ b/cli/read_and_process.py @@ -145,18 +145,20 @@ def pad_columns(processed_data): return padded_data -def remove_special_characters(data, exceptions=['.', '-']): +def remove_special_characters(data, exceptions=None): """ Remove specified characters from a dataset, excluding decimal values and English letters. Parameters: data (list or DataFrame): Dataset to process. - exceptions (list): List of characters to exempt from - removal (default is ['.'] for decimal values). + exceptions (list): List of characters to exempt from removal (default is ['.', ',']). Returns: cleaned_data (list or DataFrame): Dataset with specified characters removed. """ + if exceptions is None: + exceptions = ['.', ','] # Initialize default exceptions list inside the function + if isinstance(data, list): # If data is a list, process each element cleaned_data = [remove_special_characters(element, exceptions) for element in data]