HyukjinKwon commented on code in PR #36048:
URL: https://github.com/apache/spark/pull/36048#discussion_r849053134


##########
python/pyspark/pandas/series.py:
##########
@@ -2937,6 +2937,77 @@ def add_suffix(self, suffix: str) -> "Series":
             DataFrame(internal.with_new_sdf(sdf, index_fields=([None] * 
internal.index_level)))
         )
 
+    def autocorr(self, periods: int = 1) -> float:
+        """
+        Compute the lag-N autocorrelation.
+
+        This method computes the Pearson correlation between
+        the Series and its shifted self.
+
+        .. versionadded:: 3.4.0
+
+        Parameters
+        ----------
+        periods : int, default 1
+            Number of lags to apply before performing autocorrelation.
+
+        Returns
+        -------
+        float
+            The Pearson correlation between self and self.shift(lag).
+
+        See Also
+        --------
+        Series.corr : Compute the correlation between two Series.
+        Series.shift : Shift index by desired number of periods.
+        DataFrame.corr : Compute pairwise correlation of columns.
+
+        Notes
+        -----
+        If the Pearson correlation is not well defined return 'NaN'.

Review Comment:
   Maybe we should also add a note about the global window operation and its 
performance impact.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to