@@ -9592,6 +9592,14 @@ def corr(
9592
9592
DataFrame or Series.
9593
9593
Series.corr : Compute the correlation between two Series.
9594
9594
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
+
9595
9603
Examples
9596
9604
--------
9597
9605
>>> def histogram_intersection(a, b):
@@ -9603,7 +9611,14 @@ def corr(
9603
9611
dogs cats
9604
9612
dogs 1.0 0.3
9605
9613
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
9607
9622
numeric_df = self ._get_numeric_data ()
9608
9623
cols = numeric_df .columns
9609
9624
idx = cols .copy ()
@@ -9797,7 +9812,28 @@ def corrwith(self, other, axis: Axis = 0, drop=False, method="pearson") -> Serie
9797
9812
See Also
9798
9813
--------
9799
9814
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
9801
9837
axis = self ._get_axis_number (axis )
9802
9838
this = self ._get_numeric_data ()
9803
9839
0 commit comments