ValueError("cannot reindex from a duplicate axis") -- Only getting this error in Streamlit Cloud

I am receiving a ValueError when utilizing a function that manipulates a DataFrame. The code works fine locally, so I am wondering if this issue has to do with anything specific to Streamlit Cloud? I am utilizing st.cache for optimization and this seems to be working great locally. Could this have anything to do with Session States (not currently utilizing these)?

Repo is located here.
App is located here.

Error Log:

File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/script_runner.py", line 354, in _run_script
    exec(code, module.__dict__)
File "/app/axe_cap_terminal/terminal.py", line 1076, in <module>
    df.ta.strategy(TotalStrat)
File "/home/appuser/venv/lib/python3.7/site-packages/pandas_ta/core.py", line 778, in strategy
    getattr(self, ind["kind"])(*params, **{**ind, **kwargs})
File "/home/appuser/venv/lib/python3.7/site-packages/pandas_ta/core.py", line 1010, in macd
    result = macd(close=close, fast=fast, slow=slow, signal=signal, offset=offset, **kwargs)
File "/home/appuser/venv/lib/python3.7/site-packages/pandas_ta/momentum/macd.py", line 58, in macd
    df = DataFrame(data)
File "/home/appuser/venv/lib/python3.7/site-packages/pandas/core/frame.py", line 614, in __init__
    mgr = dict_to_mgr(data, index, columns, dtype=dtype, copy=copy, typ=manager)
File "/home/appuser/venv/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 463, in dict_to_mgr
    arrays, data_names, index, columns, dtype=dtype, typ=typ, consolidate=copy
File "/home/appuser/venv/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 122, in arrays_to_mgr
    arrays = _homogenize(arrays, index, dtype)
File "/home/appuser/venv/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 568, in _homogenize
    val = val.reindex(index, copy=False)
File "/home/appuser/venv/lib/python3.7/site-packages/pandas/core/series.py", line 4579, in reindex
    return super().reindex(index=index, **kwargs)
File "/home/appuser/venv/lib/python3.7/site-packages/pandas/core/generic.py", line 4810, in reindex
    axes, level, limit, tolerance, method, fill_value, copy
File "/home/appuser/venv/lib/python3.7/site-packages/pandas/core/generic.py", line 4834, in _reindex_axes
    allow_dups=False,
File "/home/appuser/venv/lib/python3.7/site-packages/pandas/core/generic.py", line 4880, in _reindex_with_indexers
    copy=copy,
File "/home/appuser/venv/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 663, in reindex_indexer
    self.axes[axis]._validate_can_reindex(indexer)
File "/home/appuser/venv/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3785, in _validate_can_reindex
    raise ValueError("cannot reindex from a duplicate axis")

Thank you for reading, any help is appreciated.

After further testing. It seems like certain stock tickers throw this error, while others do not. For example, these tickers throw this error:

  • NVDA
  • HD

While these tickers do not:

  • AMZN
  • GOOG

Locally, every valid ticker works:

Error on Streamlit Cloud:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.