Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

449
Visualizações
FutureWarning: The default value of regex will change from True to False in a future version

I'm running below code to clean text

import pandas as pd

def not_regex(pattern):
        return r"((?!{}).)".format(pattern)
    
tmp = pd.DataFrame(['No one has a European accent either @',
                    'That the kid   reminds me of Kevin'])

tmp[0].str.replace(not_regex('(\\b[-/]\\b|[a-zA-Z0-9])'), ' ') 

Then it returns a warning

<ipython-input-8-ef8a43f91dbd>:9: FutureWarning: The default value of regex will change from True to False in a future version.
  tmp[0].str.replace(not_regex('(\\b[-/]\\b|[a-zA-Z0-9])'), ' ')

Could you please elaborate on the reason of this warning?

over 4 years ago · Hanz Gallego
2 Respostas
Responde à pergunta

0

I have like

df.Experience.head(5)
0    24 years experience
1    12 years experience
2     9 years experience
3    12 years experience
4    20 years experience
Name: Experience, dtype: object

I use like

df['Experience']=df['Experience'].str.replace(r'\D+','', regex=True).astype(int)

I get like

df.Experience.head(5)
0    24
1    12
2     9
3    12
4    20
Name: Experience, dtype: int64
over 4 years ago · Hanz Gallego Relatório

0

See Pandas 1.2.0 release notes:

The default value of regex for Series.str.replace() will change from True to False in a future release. In addition, single character regular expressions will not be treated as literal strings when regex=True is set (GH24804)

I.e., use regular expressions explicitly now:

dframe['colname'] = dframe['colname'].str.replace(r'\D+', regex=True)
over 4 years ago · Hanz Gallego Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda