Open heresalisha opened 1 year ago
Hello. I don't know if you solved this already since this has been here for a long time. I was hesitant of writing it since no one had any more issues with it but here is a solution.
You need to either delete that column or transform it into some sort of numeric form. I would use something like this:
st.write("# Heatmap")
### Heatmap
if st.button('Heatmap'):
df_selected_team.to_csv('output.csv', index=False)
df = pd.read_csv('output.csv')
df_sel = df.drop(columns=['Pos', 'Tm','Player'], axis=1)
corr = df_sel.corr()
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8,8))
ax = sns.heatmap(corr, mask=None, vmax=1, square=True)
st.pyplot(fig)
OK will try it out
On Thu, Oct 12, 2023 at 6:23 AM Luismbpr @.***> wrote:
Hello. I don't know if you solved this already since this has been here for a long time. I was hesitant of writing it since no one had any more issues with it but here is a solution.
You need to either delete that column or transform it into some sort of numeric form. I would use something like this:
st.write("# Heatmap")### Heatmapif st.button('Heatmap'): df_selected_team.to_csv('output.csv', index=False) df = pd.read_csv('output.csv') df_sel = df.drop(columns=['Pos', 'Tm','Player'], axis=1) corr = df_sel.corr() fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8,8)) ax = sns.heatmap(corr, mask=None, vmax=1, square=True) st.pyplot(fig)
— Reply to this email directly, view it on GitHub https://github.com/dataprofessor/streamlit_freecodecamp/issues/16#issuecomment-1758749737, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZTALUK65NI4HWSDNU2MPMDX645RRANCNFSM6AAAAAAYKOFQLI . You are receiving this because you authored the thread.Message ID: @.***>
issue in heatmap
players column has first value Quincy Acy and when i click on heatmap it shows me the error below
ValueError: could not convert string to float: 'Quincy Acy' Traceback: File "C:\Users\HP\PycharmProjects\streamlit_apps\venv\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script exec(code, module.dict) File "C:\Users\HP\PycharmProjects\streamlit_apps\venv\basketball-stats-webapp.py", line 62, in
corr = df.corr()
File "C:\Users\HP\PycharmProjects\streamlit_apps\venv\lib\site-packages\pandas\core\frame.py", line 10059, in corr
mat = data.to_numpy(dtype=float, na_value=np.nan, copy=False)
File "C:\Users\HP\PycharmProjects\streamlit_apps\venv\lib\site-packages\pandas\core\frame.py", line 1838, in to_numpy
result = self._mgr.as_array(dtype=dtype, copy=copy, na_value=na_value)
File "C:\Users\HP\PycharmProjects\streamlit_apps\venv\lib\site-packages\pandas\core\internals\managers.py", line 1732, in as_array
arr = self._interleave(dtype=dtype, na_value=na_value)
File "C:\Users\HP\PycharmProjects\streamlit_apps\venv\lib\site-packages\pandas\core\internals\managers.py", line 1794, in _interleave
result[rl.indexer] = arr