From 710922e12c93042523a14e0efee44d981425765c Mon Sep 17 00:00:00 2001 From: Perdana Hadi Date: Thu, 22 Aug 2024 22:11:54 +0700 Subject: [PATCH] update to DataFrame.map() --- upload_to_sheets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upload_to_sheets.py b/upload_to_sheets.py index fa3bcfa..de9ce5c 100644 --- a/upload_to_sheets.py +++ b/upload_to_sheets.py @@ -43,7 +43,7 @@ def read_csv(file_path): # Replace NaN values with empty strings df = df.fillna('') # Convert all values to strings and strip whitespace - df = df.applymap(lambda x: str(x).strip() if isinstance(x, str) else x) + df = df.astype(str).apply(lambda x: x.str.strip()) return [df.columns.tolist()] + df.values.tolist() except FileNotFoundError: print(f"Error: CSV file not found at {file_path}")