Closed Mohitur669 closed 1 year ago
replacing the below lines:
fig, ax = plt.subplots(figsize=(20, 20))
ax = sns.heatmap(pt, annot=True)
st.pyplot(fig)
for case pt
is empty or contains null values, we need to try:
if pt is None or pt.empty:
st.write("No data available for selected country.")
else:
# Heatmap plot
fig, ax = plt.subplots(figsize=(20, 20))
ax = sns.heatmap(pt, annot=True)
st.pyplot(fig)
This will fix the bug.
Reproducing the Bug
`ValueError: 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/runtime/scriptrunner/script_runner.py", line 565, in _run_script exec(code, module.dict) File "/app/olympic-data-analysis-webapp/app.py", line 127, in
ax = sns.heatmap(pt, annot=True)
File "/home/appuser/venv/lib/python3.9/site-packages/seaborn/matrix.py", line 446, in heatmap
plotter = _HeatMapper(data, vmin, vmax, cmap, center, robust, annot, fmt,
File "/home/appuser/venv/lib/python3.9/site-packages/seaborn/matrix.py", line 163, in init
self._determine_cmap_params(plot_data, vmin, vmax,
File "/home/appuser/venv/lib/python3.9/site-packages/seaborn/matrix.py", line 202, in _determine_cmap_params
vmin = np.nanmin(calc_data)
File "<__array_function__ internals>", line 200, in nanmin
File "/home/appuser/venv/lib/python3.9/site-packages/numpy/lib/nanfunctions.py", line 343, in nanmin
res = np.fmin.reduce(a, axis=axis, out=out, **kwargs)`
Please fix the bug as soon as possible.