Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

moving averages python

# option 1

df['data'].rolling(3).mean()
df['data'].shift(periods=1).rolling(3).mean()

# option 2: compute a 9-day simple moving average

df['SMA_9'] = df['Close'].rolling(window=9, min_periods=1).mean()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #moving #averages #python
ADD COMMENT
Topic
Name
4+6 =