@@ -2491,14 +2491,67 @@ def dtypes(self) -> Series:
2491
2491
lambda df : df .dtypes , self ._selected_obj
2492
2492
)
2493
2493
2494
- @doc (DataFrame .corrwith .__doc__ )
2495
2494
def corrwith (
2496
2495
self ,
2497
2496
other : DataFrame | Series ,
2498
2497
drop : bool = False ,
2499
2498
method : CorrelationMethod = "pearson" ,
2500
2499
numeric_only : bool = False ,
2501
2500
) -> DataFrame :
2501
+ """
2502
+ Compute pairwise correlation.
2503
+
2504
+ Pairwise correlation is computed between rows or columns of
2505
+ DataFrame with rows or columns of Series or DataFrame. DataFrames
2506
+ are first aligned along both axes before computing the
2507
+ correlations.
2508
+
2509
+ Parameters
2510
+ ----------
2511
+ other : DataFrame, Series
2512
+ Object with which to compute correlations.
2513
+ drop : bool, default False
2514
+ Drop missing indices from result.
2515
+ method : {'pearson', 'kendall', 'spearman'} or callable
2516
+ Method of correlation:
2517
+
2518
+ * pearson : standard correlation coefficient
2519
+ * kendall : Kendall Tau correlation coefficient
2520
+ * spearman : Spearman rank correlation
2521
+ * callable: callable with input two 1d ndarrays
2522
+ and returning a float.
2523
+
2524
+ numeric_only : bool, default False
2525
+ Include only `float`, `int` or `boolean` data.
2526
+
2527
+ .. versionadded:: 1.5.0
2528
+
2529
+ .. versionchanged:: 2.0.0
2530
+ The default value of ``numeric_only`` is now ``False``.
2531
+
2532
+ Returns
2533
+ -------
2534
+ Series
2535
+ Pairwise correlations.
2536
+
2537
+ See Also
2538
+ --------
2539
+ DataFrame.corr : Compute pairwise correlation of columns.
2540
+
2541
+ Examples
2542
+ --------
2543
+ >>> df1 = pd.DataFrame({"Day": [1, 1, 1, 2, 2, 2, 3, 3, 3],
2544
+ ... "Data": [6, 6, 8, 5, 4, 2, 7, 3, 9]})
2545
+ >>> df2 = pd.DataFrame({"Day": [1, 1, 1, 2, 2, 2, 3, 3, 3],
2546
+ ... "Data": [5, 3, 8, 3, 1, 1, 2, 3, 6]})
2547
+
2548
+ >>> df1.groupby("Day").corrwith(df2)
2549
+ Data Day
2550
+ Day
2551
+ 1 0.917663 NaN
2552
+ 2 0.755929 NaN
2553
+ 3 0.576557 NaN
2554
+ """
2502
2555
result = self ._op_via_apply (
2503
2556
"corrwith" ,
2504
2557
other = other ,
0 commit comments