Skip to content

Commit 552152f

Browse files
committed
Initial patch to handle new pandas error
This prevents attempting to drop columns that don't exist in merged.columns after setting the index, while still dropping columns that are present in merged.columns. Attempting to do so raises an exception in pandas >= 1. Please see pandas-dev/pandas#8594 for details.
1 parent b0cc0df commit 552152f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

q2_diversity/_alpha/_visualizer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,10 @@ def _reindex_with_metadata(column, columns, merged):
241241
merged.sort_index(axis=0, ascending=True, inplace=True)
242242
merged = merged.groupby(level=[column])
243243
counts = merged.count()
244-
counts.drop(columns, axis=1, inplace=True, level=0)
244+
# Removes the column name used to set the index of `merged` above
245+
col_diff = set(columns) - set([column])
246+
if col_diff:
247+
counts.drop(col_diff, axis=1, inplace=True, level=0)
245248
median_ = merged.median()
246249
return median_, counts
247250

0 commit comments

Comments
 (0)