Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Add MultiIndex support #175

Merged
merged 5 commits into from
Jan 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/klib/describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@
return ax


def corr_interactive_plot(
def corr_interactive_plot( # noqa: C901
data: pd.DataFrame,
split: Literal["pos", "neg", "high", "low"] | None = None,
threshold: float = 0.0,
Expand Down Expand Up @@ -591,6 +591,15 @@

vtext = corr.round(2).fillna("") if annot else None

corr_columns = corr.columns
corr_index = corr.index

Check warning on line 595 in src/klib/describe.py

View check run for this annotation

Codecov / codecov/patch

src/klib/describe.py#L594-L595

Added lines #L594 - L595 were not covered by tests

if isinstance(corr_columns, pd.MultiIndex):
corr_columns = ["-".join(col) for col in corr.columns]

if isinstance(corr_index, pd.MultiIndex):
corr_index = ["-".join(idx) for idx in corr.index]

# Specify kwargs for the heatmap
kwargs = {
"colorscale": cmap,
Expand All @@ -599,8 +608,8 @@
"text": vtext,
"texttemplate": "%{text}",
"textfont": {"size": 12},
"x": corr.columns,
"y": corr.index,
"x": corr_columns,
"y": corr_index,
"z": corr,
**kwargs,
}
Expand Down