You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are two APIs the library relies on, which are deprecated as of Pandas 2.1.0:
1. Series.__getitem__ treating keys as positions
(should now use series.iloc[n] instead of series[n])
2. DataFrame.applymap
(should now use df.map instead)
This commit updates the usage of those APIs but attempts to preserve
backwards compatibility by reverting to the old behavior if something
breaks.
Copy file name to clipboardExpand all lines: plot_likert/plot_likert.py
+16-5Lines changed: 16 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -254,7 +254,10 @@ def validate(value):
254
254
f"A response was found with value `{value}`, which is not one of the values in the provided scale: {scale}. If this is unexpected, you might want to double-check for extra whitespace, capitalization, spelling, or type (int versus str)."
255
255
)
256
256
257
-
df.applymap(validate)
257
+
try:
258
+
df.map(validate)
259
+
exceptAttributeError: # for compatibility with Pandas < 2.1.0
260
+
df.applymap(validate)
258
261
259
262
# fix long questions for printing
260
263
old_labels=list(df)
@@ -289,14 +292,19 @@ def likert_percentages(
289
292
# Warn if the rows have different counts
290
293
# If they do, the percentages shouldn't be compared.
"In your data, not all questions have the same number of responses. i.e., different numbers of people answered each question. Therefore, the percentages aren't directly comparable: X% for one question represents a different number of responses than X% for another question, yet they will appear the same in the percentage graph. This may be misleading to your reader."
0 commit comments