I have a list of prices from which I want to remove all space such that the prices[0] = '2673.00'
prices = ['2 673.00', '53.55', '1 478.00', ... ]
prices = [float(x) for x in prices]
I have tried various options but none has worked for me.
x = str(prices[0]).replace(' ', '') # Got error --> ValueError: could not convert string to float: '2\xa0673.00'
import unicodedata
my_str = unicodedata.normalize("NFD", str(prices[0])) # tried ‘NFC’, ‘NFKC’, ‘NFD’, and ‘NFKD’ as different forms but got same error as above
x = str(prices[0]).replace(u'\xa0', u'') # Got error --> ValueError: could not convert string to float: '2\xa0673.00'
Please suggest a possible way. Thanks.
re.compile(r'\s+', re.U).