Fish1996
Fish1996

Reputation: 557

Reindexing only valid with uniquely valued index objects

There are a couple of articles about this issue already, but none of them solve my issue.

I have two sets of Python dataframes (df_A1, df_A2 and df_B1, df_B2) and I want to combine the A's together and the B's together. I can concat the A's just fine, but the B's give me the error 'Reindexing only valid with uniquely valued index objects'. There are a couple of causes that I found online but that won't work for me.

I have the traceback here:

Traceback (most recent call last):

  File ~\AppData\Local\anaconda3\Lib\site-packages\spyder_kernels\customize\utils.py:209 in exec_encapsulate_locals
    exec_fun(compile(code_ast, filename, "exec"), globals)

  File c:\<path>\python_script.py:168
    df_B = pd.concat([df_B1 , df_B2], axis=0, ignore_index=True)

  File ~\AppData\Local\anaconda3\Lib\site-packages\pandas\core\reshape\concat.py:395 in concat
    return op.get_result()

  File ~\AppData\Local\anaconda3\Lib\site-packages\pandas\core\reshape\concat.py:680 in get_result
    indexers[ax] = obj_labels.get_indexer(new_labels)

  File ~\AppData\Local\anaconda3\Lib\site-packages\pandas\core\indexes\base.py:3885 in get_indexer
    raise InvalidIndexError(self._requires_unique_msg)

InvalidIndexError: Reindexing only valid with uniquely valued Index objects

Does anyone has an idea on how to fix this?

Upvotes: 0

Views: 77

Answers (0)

Related Questions