Skip to content

Commit

Permalink
Use map not applymap to avoid pandas warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed Apr 26, 2024
1 parent 972115f commit 1176764
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions audplot/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ def confusion_matrix(

# Set format of first row labels in confusion matrix
if percentage:
annot = cm.applymap(lambda x: f"{100 * x:.0f}%")
annot = cm.map(lambda x: f"{100 * x:.0f}%")
else:
annot = cm.applymap(lambda x: human_format(x))
annot = cm.map(lambda x: human_format(x))

# Add a second row of annotations if requested
if show_both:
Expand All @@ -189,9 +189,9 @@ def confusion_matrix(
)
cm2 = pd.DataFrame(cm2, index=labels)
if percentage:
annot2 = cm2.applymap(lambda x: human_format(x))
annot2 = cm2.map(lambda x: human_format(x))
else:
annot2 = cm2.applymap(lambda x: f"{100 * x:.0f}%")
annot2 = cm2.map(lambda x: f"{100 * x:.0f}%")

# Combine strings from two dataframes
# by vectorizing the underlying function.
Expand Down

0 comments on commit 1176764

Please sign in to comment.