'autocorrelation_plot and plot_acf giving different result/ Difference between autocorrelation_plot and plot_acf

Please consider below code

%matplotlib inline
import pandas as pd
import numpy as np
sampleRng = pd.date_range(start='2017', periods=120, freq='MS')
sampleTs = pd.Series(np.random.randint(-10, 10, size=len(sampleRng)), sampleRng).cumsum()
sampleTs = pd.DataFrame(sampleTs,columns=['data'])
sampleTs.head()

from pandas.plotting import autocorrelation_plot
sampleTs["diff"] = sampleTs.diff() ## making data stationary

autocorrelation_plot(sampleTs["diff"])

Output is as below

enter image description here

Next lets use plot_acf from statsmodel

from statsmodels.graphics.tsaplots import plot_acf
import matplotlib.pyplot as plt
sampleTs["diff"].iloc[0] = 0
plot_acf(sampleTs["diff"], lags = 100)
plt.show()

output is as below

enter image description here

As we can notice there are clear difference between both figures. What could be the reason for this and how can we make both same.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source