Answers for "5 years moving average in yearly data in python"

0

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 with pandas

BTC_USD['SMA_9'] = BTC_USD['Close'].rolling(window=9, min_periods=1).mean()
Posted by: Guest on October-25-2020
0

12 month movinf average in python for dataframe

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
%matplotlib inline
import seaborn as sns
sns.set(style='darkgrid', context='talk', palette='Dark2')

my_year_month_fmt = mdates.DateFormatter('%m/%y')

data = pd.read_pickle('./data.pkl')
data.head(10)
Posted by: Guest on December-27-2020
0

12 month movinf average in python for dataframe

# Calculating the long-window simple moving average
long_rolling = data.rolling(window=100).mean()
long_rolling.tail()
Posted by: Guest on December-27-2020

Code answers related to "5 years moving average in yearly data in python"

Python Answers by Framework

Browse Popular Code Answers by Language