Ignoring symbols and select only numerical values with pandas
-
16-10-2019 - |
Pergunta
In one field I have entries like 'U$ 192,0'. Working on pandas, how I ignore non numerical data and get only the numerical part?
Solução
Use str.strip
if the prefix is fixed or str.replace
if not:
data = pandas.Series(["U$ 192.0"])
data.str.replace('^[^\d]*', '').astype(float)
This removes all the non-numeric characters to the left of the number, and casts to float.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a datascience.stackexchange