diff --git a/core/__main__.py b/core/__main__.py index 672c88f..09d8c86 100644 --- a/core/__main__.py +++ b/core/__main__.py @@ -5,6 +5,7 @@ import os import sys import time +import locale from concurrent import futures # Add Generated folder to module path. @@ -27,6 +28,8 @@ _ONE_DAY_IN_SECONDS = 60 * 60 * 24 _MINFLOAT = float('-inf') +# Set the locale for number formatting based on user settings +locale.setlocale(locale.LC_NUMERIC, '') class ExtensionService(SSE.ConnectorServicer): """ diff --git a/core/_clustering.py b/core/_clustering.py index 25ba2f1..2fc28f9 100644 --- a/core/_clustering.py +++ b/core/_clustering.py @@ -13,9 +13,6 @@ PARENT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(os.path.join(PARENT_DIR, 'generated')) -# Set the locale for number formatting based on user settings -locale.setlocale(locale.LC_NUMERIC, '') - class HDBSCANForQlik: """ A class to implement the HDBSCAN clustering library for Qlik. diff --git a/core/_prophet.py b/core/_prophet.py index b0e292d..c536a59 100644 --- a/core/_prophet.py +++ b/core/_prophet.py @@ -2,6 +2,7 @@ import sys import time import string +import locale import numpy as np import pandas as pd from fbprophet import Prophet @@ -165,7 +166,7 @@ def init_seasonality(cls, request): request_df = pd.DataFrame([p.split(":") for p in pairs], columns=['ds', 'y']) # Convert strings to numeric values, replace conversion errors with Null values - request_df = request_df.apply(pd.to_numeric, errors='coerce') + request_df = request_df.applymap(lambda s: locale.atof(s) if s else np.NaN) # Check if the holidays column is populated if len(holidays) > 0: