diff --git a/bigframes/series.py b/bigframes/series.py index 093fc0bf0c..7a4600a324 100644 --- a/bigframes/series.py +++ b/bigframes/series.py @@ -735,26 +735,6 @@ def round(self, decimals=0) -> "Series": return self._apply_binary_op(decimals, ops.round_op) def corr(self, other: Series, method="pearson", min_periods=None) -> float: - """ - Compute the correlation with the other Series. Non-number values are ignored in the - computation. - - Uses the "Pearson" method of correlation. Numbers are converted to float before - calculation, so the result may be unstable. - - Args: - other (Series): - The series with which this is to be correlated. - method (string, default "pearson"): - Correlation method to use - currently only "pearson" is supported. - min_periods (int, default None): - The minimum number of observations needed to return a result. Non-default values - are not yet supported, so a result will be returned for at least two observations. - - Returns: - float; Will return NaN if there are fewer than two numeric pairs, either series has a - variance or covariance of zero, or any input value is infinite. - """ # TODO(kemppeterson): Validate early that both are numeric # TODO(kemppeterson): Handle partially-numeric columns if method != "pearson": diff --git a/third_party/bigframes_vendored/pandas/core/series.py b/third_party/bigframes_vendored/pandas/core/series.py index 98c4fcdd44..10a4c195ab 100644 --- a/third_party/bigframes_vendored/pandas/core/series.py +++ b/third_party/bigframes_vendored/pandas/core/series.py @@ -809,6 +809,21 @@ def corr(self, other, method="pearson", min_periods=None) -> float: Uses the "Pearson" method of correlation. Numbers are converted to float before calculation, so the result may be unstable. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> s1 = bpd.Series([.2, .0, .6, .2]) + >>> s2 = bpd.Series([.3, .6, .0, .1]) + >>> s1.corr(s2) + -0.8510644963469901 + + >>> s1 = bpd.Series([1, 2, 3], index=[0, 1, 2]) + >>> s2 = bpd.Series([1, 2, 3], index=[2, 1, 0]) + >>> s1.corr(s2) + -1.0 + Args: other (Series): The series with which this is to be correlated.