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

Fix streamlit part 5 error: ArrowTypeError: ("Expected bytes, got a 'int' object", 'Conversion failed for column FG% with type object') #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion streamlit/part5/basketball_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def load_data(year):
raw = df.drop(df[df.Age == 'Age'].index) # Deletes repeating headers in content
raw = raw.fillna(0)
playerstats = raw.drop(['Rk'], axis=1)
for i in playerstats.filter(regex='%').columns:
playerstats[i] = playerstats[i].astype(float)
return playerstats
playerstats = load_data(selected_year)

Expand All @@ -43,6 +45,7 @@ def load_data(year):
st.write('Data Dimension: ' + str(df_selected_team.shape[0]) + ' rows and ' + str(df_selected_team.shape[1]) + ' columns.')
st.dataframe(df_selected_team)


# Download NBA player stats data
# https://discuss.streamlit.io/t/how-to-download-file-in-streamlit/1806
def filedownload(df):
Expand All @@ -65,4 +68,4 @@ def filedownload(df):
with sns.axes_style("white"):
f, ax = plt.subplots(figsize=(7, 5))
ax = sns.heatmap(corr, mask=mask, vmax=1, square=True)
st.pyplot()
st.pyplot(f)