Skip to content

Commit

Permalink
Updated string to numeric conversions in Prophet to use locale settings.
Browse files Browse the repository at this point in the history
Signed-off-by: Nabeel <Nabeel.Asif@qlik.com>
  • Loading branch information
nabeel-oz committed May 28, 2018
1 parent 878a28c commit 4cae1f2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 3 additions & 0 deletions core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import sys
import time
import locale
from concurrent import futures

# Add Generated folder to module path.
Expand All @@ -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):
"""
Expand Down
3 changes: 0 additions & 3 deletions core/_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion core/_prophet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import time
import string
import locale
import numpy as np
import pandas as pd
from fbprophet import Prophet
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 4cae1f2

Please sign in to comment.