Skip to content

Commit d18fe84

Browse files
committed
Initial path 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 see raises an exception in pandas >= 1. Please see pandas-dev/pandas#8594 for details.
1 parent b0cc0df commit d18fe84

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

q2_diversity/_alpha/_visualizer.py

+4-1
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)