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

418
Visualizações
calculate Exponential Moving Average with pandas

I try to calculate ema with pandas but the result is not good. I try 2 techniques to calculate :

The first technique is the panda's function ewn:

window = 100
c = 2 / float(window + 1)
df['100ema'] = df['close'].ewm(com=c).mean()

But the last result of this function gives. 2695.4 but the real result is 2656.2

The second technique is

window = 100
c = 2 / float(window + 1)
df['100sma'] = df['close'].rolling(window).mean()
df['100ema'] = (c * df['close']) + ((1 - c) * df['100sma'])

The result is 2649.1 it's closer than first technique but is always not good

The sma function give the good result

** EDIT **

The response is

df['100ema'] = pd.Series.ewm(df['close'], span=window).mean()
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

If you want to calculate EWMA or any technical indicator in Python, I recommend using ta-lib.

over 4 years ago · Santiago Trujillo Relatório

0

expwighted_avg = ts_log.ewm(halflife=12).mean()

where 'ts_log' is dataframe or series of Time Series

over 4 years ago · Santiago Trujillo 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