From dc302bf7b5e89b537f6920550bac68660f316e34 Mon Sep 17 00:00:00 2001 From: perezgonzalez-irene <iregon@noc.ac.uk> Date: Wed, 4 Mar 2020 12:12:52 +0000 Subject: [PATCH] Changed replacement method back to str method, but managing all nan before --- common/converters.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/converters.py b/common/converters.py index faf5c9c..5828075 100644 --- a/common/converters.py +++ b/common/converters.py @@ -39,7 +39,9 @@ class df_converters(): offset = offset if offset else self.numeric_offset # First do the appropriate managing of white spaces, to the right, they mean 0! data = data.replace(r'^\s*$', np.nan, regex=True) - data = data.replace(' ', '0') + # str method fails if all nan + 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 -- GitLab