ValueError: cannot reindex from a duplicate axis (could use better error)
- Dominant language
- Python
- Stars
- 92
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
I've been playing around with CTF and have occasionally noticed the following error
```
Traceback (most recent call last):
File "/home/juermieboop/miniconda3/envs/qiime2-2020.8/lib/python3.6/site-packages/q2cli/commands.py", line 329, in __call__
results = action(**arguments)
File "", line 2, in ctf
File "/home/juermieboop/miniconda3/envs/qiime2-2020.8/lib/python3.6/site-packages/qiime2/sdk/action.py", line 245, in bound_callable
output_types, provenance)
File "/home/juermieboop/miniconda3/envs/qiime2-2020.8/lib/python3.6/site-packages/qiime2/sdk/action.py", line 390, in _callable_executor_
output_views = self._callable(**view_args)
File "/home/juermieboop/miniconda3/envs/qiime2-2020.8/lib/python3.6/site-packages/gemelli/ctf.py", line 40, in ctf
feature_metadata)
File "/home/juermieboop/miniconda3/envs/qiime2-2020.8/lib/python3.6/site-packages/gemelli/ctf.py", line 187, in ctf_helper
straj = concat([straj.reindex(all_sample_metadata.index),
File "/home/juermieboop/miniconda3/envs/qiime2-2020.8/lib/python3.6/site-packages/pandas/util/_decorators.py", line 221, in wrapper
return func(*args, **kwargs)
File "/home/juermieboop/miniconda3/envs/qiime2-2020.8/lib/python3.6/site-packages/pandas/core/frame.py", line 3976, in reindex
return super().reindex(**kwargs)
File "/home/juermieboop/miniconda3/envs/qiime2-2020.8/lib/python3.6/site-packages/pandas/core/generic.py", line 4514, in reindex
axes, level, limit, tolerance, method, fill_value, copy
File "/home/juermieboop/miniconda3/envs/qiime2-2020.8/lib/python3.6/site-packages/pandas/core/frame.py", line 3864, in _reindex_axes
index, method, copy, level, fill_value, limit, tolerance
File "/home/juermieboop/miniconda3/envs/qiime2-2020.8/lib/python3.6/site-packages/pandas/core/frame.py", line 3886, in _reindex_index
allow_dups=False,
File "/home/juermieboop/miniconda3/envs/qiime2-2020.8/lib/python3.6/site-packages/pandas/core/generic.py", line 4577, in _reindex_with_indexers
copy=copy,
File "/home/juermieboop/miniconda3/envs/qiime2-2020.8/lib/python3.6/site-packages/pandas/core/internals/managers.py", line 1251, in reindex_indexer
self.axes[axis]._can_reindex(indexer)
File "/home/juermieboop/miniconda3/envs/qiime2-2020.8/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 3362, in _can_reindex
raise ValueError("cannot reindex from a duplicate axis")
ValueError: cannot reindex from a duplicate axis
```
Turns out that the error pops up if there are duplicates in the state-column, and the error goes away of these duplicates are removed (i.e. if week 3 is repeated twice within the same host, it'll throw an error).
It could be nice if a more informative error was thrown.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in gemelli/ctf.py, in ctf_helper around the reindex call shown in the traceback. Reproduce the failure with duplicate state-column entries within one host, then verify that the resulting error identifies the duplicate metadata condition instead of exposing pandas' generic ValueError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- pandas, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100