# Computing correlation of each row

This discussion will cover computing the correlation between each row and its succeeding row. Correlation measures the strength and direction of the linear relationship between variables, ranging from -1 to 1. It is a statistical measure used to identify patterns and relationships between variables, which can be helpful for data analysis, modeling, and prediction. By computing the correlation of each row, we can determine which variables are strongly related and which are not. Several methods can be used to compute the correlation between each row and its succeeding row in a Pandas DataFrame.

#### 1. Using the "corr()" method:

The simplest way to compute the correlation of each row with the succeeding row is to use the Pandas `corr()` method. This method computes the correlation between each pair of columns or rows in a DataFrame. By default, `corr()` computes the Pearson correlation coefficient, which measures the linear relationship between two variables.

#### 2. Using "rolling()":

Another way to compute the correlation of each row with the succeeding row is to use the `rolling()` method, which applies a rolling window function to a DataFrame. You can use `rolling()` to compute the correlation between each pair of rows within a rolling window of size 2.

#### 3. Using "apply()":

Another way to compute the correlation of each row with the succeeding row is to use the `apply()` method, which applies a function to each row or column of a DataFrame. You can define a custom function that computes the correlation between each row and the succeeding row, and then apply this function to each pair of rows using `apply()` .