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

Exception: cannot reindex from a duplicate axis #28

Closed
graceyangfan opened this issue Sep 23, 2022 · 0 comments
Closed

Exception: cannot reindex from a duplicate axis #28

graceyangfan opened this issue Sep 23, 2022 · 0 comments

Comments

@graceyangfan
Copy link

graceyangfan commented Sep 23, 2022

Hello,I meet this error several time,The full info is:
I check my pandas dataframe sveral time,There is no duplicate axis.
My X and y like:
image

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/tuneta/optimize.py", line 128, in eval_res
    res = eval(function)
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/pandas_ta/volume/kvo.py", line 51, in kvo
    df = DataFrame(data)
  File "/usr/local/lib/python3.9/dist-packages/pandas/core/frame.py", line 614, in __init__
    mgr = dict_to_mgr(data, index, columns, dtype=dtype, copy=copy, typ=manager)
  File "/usr/local/lib/python3.9/dist-packages/pandas/core/internals/construction.py", line 464, in dict_to_mgr
    return arrays_to_mgr(
  File "/usr/local/lib/python3.9/dist-packages/pandas/core/internals/construction.py", line 124, in arrays_to_mgr
    arrays = _homogenize(arrays, index, dtype)
  File "/usr/local/lib/python3.9/dist-packages/pandas/core/internals/construction.py", line 571, in _homogenize
    val = val.reindex(index, copy=False)
  File "/usr/local/lib/python3.9/dist-packages/pandas/core/series.py", line 4580, in reindex
    return super().reindex(index=index, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/pandas/core/generic.py", line 4818, in reindex
    return self._reindex_axes(
  File "/usr/local/lib/python3.9/dist-packages/pandas/core/generic.py", line 4839, in _reindex_axes
    obj = obj._reindex_with_indexers(
  File "/usr/local/lib/python3.9/dist-packages/pandas/core/generic.py", line 4883, in _reindex_with_indexers
    new_data = new_data.reindex_indexer(
  File "/usr/local/lib/python3.9/dist-packages/pandas/core/internals/managers.py", line 670, in reindex_indexer
    self.axes[axis]._validate_can_reindex(indexer)
  File "/usr/local/lib/python3.9/dist-packages/pandas/core/indexes/base.py", line 3785, in _validate_can_reindex
    raise ValueError("cannot reindex from a duplicate axis")
ValueError: cannot reindex from a duplicate axis

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/multiprocess/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/usr/local/lib/python3.9/dist-packages/tuneta/optimize.py", line 237, in fit
    self.study.optimize(
  File "/usr/local/lib/python3.9/dist-packages/optuna/study/study.py", line 419, in optimize
    _optimize(
  File "/usr/local/lib/python3.9/dist-packages/optuna/study/_optimize.py", line 66, in _optimize
    _optimize_sequential(
  File "/usr/local/lib/python3.9/dist-packages/optuna/study/_optimize.py", line 160, in _optimize_sequential
    frozen_trial = _run_trial(study, func, catch)
  File "/usr/local/lib/python3.9/dist-packages/optuna/study/_optimize.py", line 234, in _run_trial
    raise func_err
  File "/usr/local/lib/python3.9/dist-packages/optuna/study/_optimize.py", line 196, in _run_trial
    value_or_values = func(trial)
  File "/usr/local/lib/python3.9/dist-packages/tuneta/optimize.py", line 238, in <lambda>
    lambda trial: _objective(self, trial, X, y),
  File "/usr/local/lib/python3.9/dist-packages/tuneta/optimize.py", line 162, in _objective
    res = eval_res(X, self.function, self.idx, trial)
  File "/usr/local/lib/python3.9/dist-packages/tuneta/optimize.py", line 131, in eval_res
    raise Exception(e)
Exception: cannot reindex from a duplicate axis
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/notebooks/feature_select.py", line 197, in <module>
    tt.fit(X_train, y_train,
  File "/usr/local/lib/python3.9/dist-packages/tuneta/tune_ta.py", line 197, in fit
    self.fitted = [fit.get() for fit in self.fitted]
  File "/usr/local/lib/python3.9/dist-packages/tuneta/tune_ta.py", line 197, in <listcomp>
    self.fitted = [fit.get() for fit in self.fitted]
  File "/usr/local/lib/python3.9/dist-packages/multiprocess/pool.py", line 771, in get
    raise self._value
Exception: cannot reindex from a duplicate axis

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

2 participants
@graceyangfan and others