From 4e59e1cee0c282bd0387eedd1982a9ebceb0116d Mon Sep 17 00:00:00 2001
From: perezgonzalez-irene <iregon@noc.ac.uk>
Date: Thu, 5 Mar 2020 09:36:53 +0000
Subject: [PATCH] Changed to pandas nullable integers management

---
 common/converters.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/common/converters.py b/common/converters.py
index 5828075..f7e01a4 100644
--- a/common/converters.py
+++ b/common/converters.py
@@ -37,18 +37,18 @@ class df_converters():
         
         scale = scale if scale else self.numeric_scale
         offset = offset if offset else self.numeric_offset
-        # First do the appropriate managing of white spaces, to the right, they mean 0!
+        # First do the appropriate managing of white spaces:
+        # to the right, they should mean 0!
         data = data.replace(r'^\s*$', np.nan, regex=True)
-        # str method fails if all nan
+        # str method fails if all nan, pd.Series.replace method is not the same
+        # as pd.Series.str.replace!
         if data.count() > 0:
             data = data.str.replace(' ', '0')
         #  Convert to numeric, then scale (?!) and give it's actual int type
         data = pd.to_numeric(data,errors = 'coerce') # astype fails on strings, to_numeric manages errors....!
         data = offset + data * scale
-        try:
-            return data.astype(self.dtype, casting = 'safe')
-        except:
-            return data
+        
+        return pd.Series(data,dtype = self.dtype)      
 
     def object_to_object(self,data,disable_white_strip = False):
         # With strip() an empty element after stripping, is just an empty element, no NaN...
-- 
GitLab