Skip to content

Commit

Permalink
fix: cramer's correlation fails with missings vals (#1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbarros authored and vascoalramos committed Oct 20, 2022
1 parent 535d979 commit 8e7f8b2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/pandas_profiling/model/pandas/correlations_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ def pandas_cramers_compute(

for name1, name2 in itertools.combinations(categoricals, 2):
confusion_matrix = pd.crosstab(df[name1], df[name2])
correlation_matrix.loc[name2, name1] = _cramers_corrected_stat(
confusion_matrix, correction=True
)
if confusion_matrix.empty:
correlation_matrix.loc[name2, name1] = np.nan
else:
correlation_matrix.loc[name2, name1] = _cramers_corrected_stat(
confusion_matrix, correction=True
)
correlation_matrix.loc[name1, name2] = correlation_matrix.loc[name2, name1]
return correlation_matrix

Expand Down

0 comments on commit 8e7f8b2

Please sign in to comment.