Can't deploy pandas dataframe

Hi all, I tried to deploy a dataframe.head() in my app and it shows an error (attached). My local environment works fine so I guess it’s not my code. I included an app dependencies text file that includes pandas==1.3

The way I open my dataset is:

# Load data
order_history = pd.read_csv("datasets\Retail.OrderHistory.1.csv")
st.dataframe(order_history.head())

The datasets folder is inside the folder where my main.py app is located.

Hope someone can help. Thank you

Hi @aleivaar,

Can you share the full error message?

Caroline :balloon:

Hi @Caroline, it seems the problem is that the path is not relative. I found a similar post that has a similar issue (Loading our own datasets - #4 by irrelevantRyan).

I added the following code based on the explanation in the above link, but still doesn’t work.

from pathlib import Path

order_history_csv = Path(__file__).parents[1] / 'datasets/Retail.OrderHistory.1.csv'

The error message is:

IndexError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you're on Streamlit Cloud, click on 'Manage app' in the lower right of your app).
Traceback:
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.py", line 557, in _run_script
    exec(code, module.__dict__)
File "Renew-Amazon-Prime.py", line 60, in <module>
    order_history_csv = Path(__file__).parents[1] / 'datasets/Retail.OrderHistory.1.csv'
File "/usr/local/lib/python3.9/pathlib.py", line 645, in __getitem__
    raise IndexError(idx)

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