When I run the code below locally it works well without any problems.
But When I deploy the apps it is not working anymore.
Attach links to the apps below with the errors
The issue in anomaly detection is that spy columns is a multiindex with levels “Price” and “Ticker”, but ticker is the empty string in some cases. Add this right before the error to check:
Some of my colums like upper,lower,SMA are with Nan and contain empty cells.
But in my local environment i didn’t get any error.
Also it filter the data frame well in my local environment.
Why there is a gap between the cloud and the local environment?
Do you know how to fix it ?
As I said, that is probably due to different versions of something, maybe yfinance. If you want both environments to behave the same, make sure you use the same versions of everything.
File "/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
result = func()
^^^^^^File "/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 579, in code_to_exec
exec(code, module.__dict__)File "/mount/src/anomaly-detection-option-price-/pages/Anomaly detection.py", line 25, in <module>
spy.columns = spy.columns.droplevel(symbol)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/home/adminuser/venv/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 2155, in droplevel
levnums = sorted(self._get_level_number(lev) for lev in level)[::-1]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/home/adminuser/venv/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 2155, in <genexpr>
levnums = sorted(self._get_level_number(lev) for lev in level)[::-1]
^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/home/adminuser/venv/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 2017, in _get_level_number
self._validate_index_level(level)File "/home/adminuser/venv/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 2012, in _validate_index_level
raise KeyError(
I used the same versions.
I don’t know why if i have empty cell in the data frame it not working in the cloud
while in the local environment all is working well.
Yeah, the change you made cannot work. Is there a reason why you don’t want to make the change I suggested?
Well, I cannot access your local environment so I can’t tell for sure what’s going on. All I can do is making suggestions. I have seen people being wrong about what versions they were using and even what code they were running. So I suggest you double check.
But I cannot find that in your repo, neither in the last commit so far nor in any of the recent ones. It looks like you never made that change. Am I missing something?
Hey dude, I had a similar problem in my code, and your solution fixed it. I don’t know exactly why this was happening to begin with, I remember testing my code in the cloud a few weeks ago and it worked just fine but now it just didn’t work without your solution. Thanks a lot!