|
26 | 26 | def pandas_spearman_compute( |
27 | 27 | config: Settings, df: pd.DataFrame, summary: dict |
28 | 28 | ) -> Optional[pd.DataFrame]: |
29 | | - return df.corr(method="spearman") |
| 29 | + df_aux = df.select_dtypes(include="number").copy() |
| 30 | + return df_aux.corr(method="spearman") |
30 | 31 |
|
31 | 32 |
|
32 | 33 | @Pearson.compute.register(Settings, pd.DataFrame, dict) |
33 | 34 | def pandas_pearson_compute( |
34 | 35 | config: Settings, df: pd.DataFrame, summary: dict |
35 | 36 | ) -> Optional[pd.DataFrame]: |
36 | | - return df.corr(method="pearson") |
| 37 | + df_aux = df.select_dtypes(include="number").copy() |
| 38 | + return df_aux.corr(method="pearson") |
37 | 39 |
|
38 | 40 |
|
39 | 41 | @Kendall.compute.register(Settings, pd.DataFrame, dict) |
40 | 42 | def pandas_kendall_compute( |
41 | 43 | config: Settings, df: pd.DataFrame, summary: dict |
42 | 44 | ) -> Optional[pd.DataFrame]: |
43 | | - return df.corr(method="kendall") |
| 45 | + df_aux = df.select_dtypes(include="number").copy() |
| 46 | + return df_aux.corr(method="kendall") |
44 | 47 |
|
45 | 48 |
|
46 | 49 | def _cramers_corrected_stat(confusion_matrix: pd.DataFrame, correction: bool) -> float: |
@@ -195,7 +198,7 @@ def pandas_auto_compute( |
195 | 198 |
|
196 | 199 | method = ( |
197 | 200 | _pairwise_spearman |
198 | | - if col_1_name and col_2_name not in categorical_columns |
| 201 | + if any(elem in categorical_columns for elem in [col_1_name, col_2_name]) is False |
199 | 202 | else _pairwise_cramers |
200 | 203 | ) |
201 | 204 |
|
|
0 commit comments