- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Assume, you have series and the result for autocorrelation with lag 2 is,

Series is: 0 2.0 1 10.0 2 3.0 3 4.0 4 9.0 5 10.0 6 2.0 7 NaN 8 3.0 dtype: float64 series correlation: -0.4711538461538461 series correlation with lags: -0.2933396642805515

To solve this, we will follow the steps given below −

Define a series

Find the series autocorrelation using the below method,

series.autocorr()

Calculate the autocorrelation with lag=2 as follows,

series.autocorr(lag=2)

Let’s see the below code to get a better understanding,

import pandas as pd import numpy as np series = pd.Series([2, 10, 3, 4, 9, 10, 2, np.nan, 3]) print("Series is:\n", series) print("series correlation:\n",series.autocorr()) print("series correlation with lags:\n",series.autocorr(lag=2))

Series is: 0 2.0 1 10.0 2 3.0 3 4.0 4 9.0 5 10.0 6 2.0 7 NaN 8 3.0 dtype: float64 series correlation: -0.4711538461538461 series correlation with lags: -0.2933396642805515

- Related Questions & Answers
- Write a program in Python to print the elements in a series between a specific range
- Write a C program to find out the largest and smallest number in a series
- Write a Python program to separate a series of alphabets and digits and convert them to a dataframe
- Python Program to Input a Number n and Compute n+nn+nnn
- Write a program in Python to count the total number of integer, float and object data types in a given series
- Write a program in Python to compute grouped data covariance and calculate grouped data covariance between two columns in a given dataframe
- Write a program in Python to filter valid dates in a given series
- Write a program in Python to filter armstrong numbers in a given series
- Write a Python program to shuffle all the elements in a given series
- Write a program in Python to generate any random five prime numbers between 100 to 150 in a Series
- Write a Python program to count the total number of ages between 20 to 30 in a DataFrame
- Python Program for nth multiple of a number in Fibonacci Series
- Write a program in Python to find the maximum length of a string in a given Series
- Write a program in Python to filter only integer elements in a given series
- Write a program in Python to round all the elements in a given series

Advertisements