generalized_corrwith#
- generalized_corrwith(x1: DataFrame, x2: DataFrame, method: Callable)[source]#
Compute pairwise correlation.
Pairwise correlation is computed between columns of one DataFrame with columns of another DataFrame. Pandas’ method corrwith only applies when both dataframes have the same column names, this generalized method applies to any two Dataframes with the same number of rows, regardless of the column names.
- Parameters
- x1: DataFrame
Left data frame to compute correlations.
- x2: Dataframe
Right data frame to compute correlations.
- method: Callable
Method of correlation. callable with input two 1d ndarrays and returning a float.
- Returns
- DataFrame
Pairwise correlations, the index matches the columns of x1 and the columns match the columns of x2.