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!
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.