Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: cannot reindex from a duplicate axis (could use better error) #45

Open
mortonjt opened this issue Apr 7, 2021 · 0 comments

Comments

@mortonjt
Copy link

mortonjt commented Apr 7, 2021

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 "<decorator-gen-538>", 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant