Python error locale

Asked

Viewed 361 times

0

locale.setlocale(locale.LC_ALL, "Portuguese_Brazil.1252")
data = pd.read_excel('C:/Users/t714591/Videos/bancos/base.xlsx')

data["Valor"] = locale.currency(data["Valor"], grouping=True, symbol=None)

I have this mistake when I use the locale to convert the number to EN:

"{0}".format(str(converter)))

Typeerror: cannot Convert the series to

  • This is because you are passing a series of pandas, but the function expects a number. If you want to format all values, see how to map them

  • I understood and how can I change each one ?

1 answer

0

I managed to solve using lambda:

data["Valor"] = data.Valor.apply(lambda x: locale.currency(x, grouping=True, symbol=None))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.