Search
 
SCRIPT & CODE EXAMPLE
 

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()
Comment

PREVIOUS NEXT
Code Example
Python :: Calculate Euclidean Distance in Python using distance.euclidean() 
Python :: how to convert a list to dataframe in python 
Python :: filter one dataframe by another 
Python :: python order by date 
Python :: convert list to dataframe 
Python :: can list comprehenios contain else 
Python :: one line if statement no else 
Python :: fcm_django 
Python :: Python how to compile to exe file 
Python :: tab of nbextensions not showing in jupyter notebook 
Python :: how to convert all items in a list to integer python 
Python :: python show charracter code 
Python :: pandas change dtype 
Python :: how to change the values of a column in numpy array 
Python :: python list of dictionaries to excel 
Python :: how to install api in python 
Python :: dummy variables pandas 
Python :: check if array is empty python 
Python :: max pooling in cnn 
Python :: python read json file array 
Python :: slug url 
Python :: Python NumPy split Function Example 
Python :: custom jupyter notebook 
Python :: how to do a mac vendor lookup in python 
Python :: charat in python 
Python :: how to use label encoding in python 
Python :: create qr code in python 
Python :: python sort the values in a dictionary 
Python :: randomly shuffle pandas dataframe 
Python :: how to open cmd at specific size using python 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =