Skip to content

Commit

Permalink
fix: use deterministic column order for correlations heatmap (#1507)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
alexbarros authored Nov 21, 2023
1 parent 3d90f2a commit 93e7430
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ plugins:
lang: en
- autorefs
- mkdocstrings:
custom_templates: templates
default_handler: python
handlers:
python:
Expand Down
4 changes: 3 additions & 1 deletion src/ydata_profiling/model/pandas/correlations_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def pandas_cramers_compute(
if len(categoricals) <= 1:
return None

categoricals = sorted(categoricals)
matrix = np.zeros((len(categoricals), len(categoricals)))
np.fill_diagonal(matrix, 1.0)
correlation_matrix = pd.DataFrame(
Expand Down Expand Up @@ -183,7 +184,8 @@ def pandas_auto_compute(
df_discretized = Discretizer(
DiscretizationType.UNIFORM, n_bins=config.correlations["auto"].n_bins
).discretize_dataframe(df)
columns_tested = numerical_columns + categorical_columns
columns_tested = sorted(numerical_columns + categorical_columns)

correlation_matrix = pd.DataFrame(
np.ones((len(columns_tested), len(columns_tested))),
index=columns_tested,
Expand Down

0 comments on commit 93e7430

Please sign in to comment.