Treemap on plotly express not working with Pandas 2.0.2

I am adding a tree map to my Strealit app. I am inclined to use plotly to visualise the TreeMap. However when I execute my code, plotly express is trying to append to a dataframe which is something you can’t do beyond pandas 1.5.3. Streamlit is using Pandas 2.0 now.

Here’s my app link: https://liu3388-msa-returns-dashboard-msa-returns-54ymex.streamlit.app/

and here’s (part of) the traceback:
File “/home/appuser/venv/lib/python3.9/site-packages/plotly/express/_core.py”, line 1637, in process_dataframe_hierarchy
df_all_trees = df_all_trees.append(df_tree, ignore_index=True)

I fixed the _core.py on my local machine so the append function is now a concat function and it works:

df_all_trees = pd.concat([df_all_trees, df_tree], ignore_index=True)

But how do I do that with Streamlit cloud’s _core.py? or is there another way?

Tks!

Hello there,
In Streamlit, you don’t have direct control over the version of the packages installed on the Streamlit Cloud servers. However, you can work around this issue by creating a custom Python environment using a requirements.txt file that specifies the desired package versions.

Streamlit Cloud will use the specified Pandas version from the requirements.txt file instead of the default version installed on the servers. This allows you to control the package versions and ensure compatibility with your code.

That worked! Tks!

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