Skip to content

Commit 93e7430

Browse files
authored
fix: use deterministic column order for correlations heatmap (#1507)
* fix: corr heatmap using deterministic col order * fix: sort cramers heatmap columns * fix: avoid errors from missidentified types * fix: config error caused by increased version
1 parent 3d90f2a commit 93e7430

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

mkdocs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ plugins:
134134
lang: en
135135
- autorefs
136136
- mkdocstrings:
137-
custom_templates: templates
138137
default_handler: python
139138
handlers:
140139
python:

src/ydata_profiling/model/pandas/correlations_pandas.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def pandas_cramers_compute(
104104
if len(categoricals) <= 1:
105105
return None
106106

107+
categoricals = sorted(categoricals)
107108
matrix = np.zeros((len(categoricals), len(categoricals)))
108109
np.fill_diagonal(matrix, 1.0)
109110
correlation_matrix = pd.DataFrame(
@@ -183,7 +184,8 @@ def pandas_auto_compute(
183184
df_discretized = Discretizer(
184185
DiscretizationType.UNIFORM, n_bins=config.correlations["auto"].n_bins
185186
).discretize_dataframe(df)
186-
columns_tested = numerical_columns + categorical_columns
187+
columns_tested = sorted(numerical_columns + categorical_columns)
188+
187189
correlation_matrix = pd.DataFrame(
188190
np.ones((len(columns_tested), len(columns_tested))),
189191
index=columns_tested,

0 commit comments

Comments
 (0)