Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App 3 : EDA basket ball #16

Open
heresalisha opened this issue May 22, 2023 · 2 comments
Open

App 3 : EDA basket ball #16

heresalisha opened this issue May 22, 2023 · 2 comments

Comments

@heresalisha
Copy link

heresalisha commented May 22, 2023

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

@Luismbpr
Copy link

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)

@heresalisha
Copy link
Author

heresalisha commented Oct 12, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants