Skip to content

Commit b61cb62

Browse files
alexbarrosaquemy
authored andcommitted
fix: correlation between columns w/o nonnull row
1 parent caf884b commit b61cb62

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/ydata_profiling/model/pandas/correlations_pandas.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ def _cramers_corrected_stat(confusion_matrix: pd.DataFrame, correction: bool) ->
5353
Returns:
5454
The Cramer's V corrected stat for the two variables.
5555
"""
56+
# handles empty crosstab
57+
if confusion_matrix.empty:
58+
return 0
59+
5660
chi2 = stats.chi2_contingency(confusion_matrix, correction=correction)[0]
5761
n = confusion_matrix.sum().sum()
5862
phi2 = chi2 / n

0 commit comments

Comments
 (0)