Skip to content

Commit

Permalink
update mutable default argument
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGellis committed Sep 4, 2024
1 parent 7081268 commit 9688142
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cli/read_and_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 9688142

Please sign in to comment.