@@ -9592,6 +9592,14 @@ def corr(
95929592 DataFrame or Series.
95939593 Series.corr : Compute the correlation between two Series.
95949594
9595+ Notes
9596+ -----
9597+ Pearson, Kendall and Spearman correlation are currently computed using pairwise complete observations.
9598+
9599+ * `Pearson correlation coefficient <https://en.wikipedia.org/wiki/Pearson_correlation_coefficient>`_
9600+ * `Kendall rank correlation coefficient <https://en.wikipedia.org/wiki/Kendall_rank_correlation_coefficient>`_
9601+ * `Spearman's rank correlation coefficient <https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient>`_
9602+
95959603 Examples
95969604 --------
95979605 >>> def histogram_intersection(a, b):
@@ -9603,7 +9611,14 @@ def corr(
96039611 dogs cats
96049612 dogs 1.0 0.3
96059613 cats 0.3 1.0
9606- """
9614+
9615+ >>> df = pd.DataFrame([(1, 1), (2, np.nan), (np.nan, 3), (4, 4)],
9616+ ... columns=['dogs', 'cats'])
9617+ >>> df.corr(min_periods=3)
9618+ dogs cats
9619+ dogs 1.0 NaN
9620+ cats NaN 1.0
9621+ """ # noqa:E501
96079622 numeric_df = self ._get_numeric_data ()
96089623 cols = numeric_df .columns
96099624 idx = cols .copy ()
@@ -9797,7 +9812,28 @@ def corrwith(self, other, axis: Axis = 0, drop=False, method="pearson") -> Serie
97979812 See Also
97989813 --------
97999814 DataFrame.corr : Compute pairwise correlation of columns.
9800- """
9815+
9816+ Examples
9817+ --------
9818+ >>> index = ["a", "b", "c", "d", "e"]
9819+ >>> columns = ["one", "two", "three", "four"]
9820+ >>> df1 = pd.DataFrame(np.arange(20).reshape(5, 4), index=index, columns=columns)
9821+ >>> df2 = pd.DataFrame(np.arange(16).reshape(4, 4), index=index[:4], columns=columns)
9822+ >>> df1.corrwith(df2)
9823+ one 1.0
9824+ two 1.0
9825+ three 1.0
9826+ four 1.0
9827+ dtype: float64
9828+
9829+ >>> df2.corrwith(df1, axis=1)
9830+ a 1.0
9831+ b 1.0
9832+ c 1.0
9833+ d 1.0
9834+ e NaN
9835+ dtype: float64
9836+ """ # noqa:E501
98019837 axis = self ._get_axis_number (axis )
98029838 this = self ._get_numeric_data ()
98039839
0 commit comments