Learn how to build interactive and data-driven web apps in Python using the Streamlit library.
Video | Title |
---|---|
Build 12 Data Science Apps with Python and Streamlit - Full Course |
Build 12 Data Apps in Python with Streamlit
Learn how to build interactive and data-driven web apps in Python using the Streamlit library.
Video | Title |
---|---|
Build 12 Data Science Apps with Python and Streamlit - Full Course |
Hello, while launching the boston house regression app (app 9) I get this error:
KeyError: <class 'numpy.float64'>
Traceback:
File "/home/xxx/anaconda3/envs/stl/lib/python3.8/site-packages/streamlit/script_runner.py", line 332, in _run_script
exec(code, module.dict)
File "/home/xxx/github/streamlit_freecodecamp/app_9_regression_boston_housing/boston-house-ml-app.py", line 54, in
df = user_input_features()
File "/home/xxx/github/streamlit_freecodecamp/app_9_regression_boston_housing/boston-house-ml-app.py", line 25, in user_input_features
CRIM = st.sidebar.slider('CRIM', X.CRIM.min(), X.CRIM.max(), X.CRIM.mean())
File "/home/xxx/anaconda3/envs/stl/lib/python3.8/site-packages/streamlit/elements/slider.py", line 159, in slider
data_type = SUPPORTED_TYPES[type(value[0])]
It seems there something odd between the format in which data in the sidebar are saved and the way the program expects them?
Any help is appreciated!
Thanks
URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)>
Hello there I am new to programming entirely. But I found this a little easy so I thought of starting from here. I managed to download and install Anaconda, make a new environment, write the entire code but at last I am having problems with the streamlit app. It says [AttributeError: 'DataFrame' object has no attribute 'close']
The programme is same 2 same. If you could point me into the right direct that would be great
I am attaching snapshot of the issue.
AttributeError: 'DataFrame' object has no attribute 'close'
Traceback:
File "c:\programdata\anaconda3\lib\site-packages\streamlit\script_runner.py", line 337, in _run_script
exec(code, module.dict)
File "C:\Users\shubh\PycharmProjects\pythonProject1\1.py", line 21, in
st.line_chart(tickerDf.close)
File "c:\programdata\anaconda3\lib\site-packages\pandas\core\generic.py", line 5139, in getattr
return object.getattribute(self, name)
File "/home/user/.local/lib/python3.9/site-packages/streamlit/script_runner.py", line 354, in _run_script
exec(code, module.__dict__)
File "/media/user/Data/streamlit_freecodecamp/app_6_eda_cryptocurrency/app.py", line 105, in <module>
df = load_data()
File "/home/user/.local/lib/python3.9/site-packages/streamlit/legacy_caching/caching.py", line 543, in wrapped_func
return get_or_create_cached_value()
File "/home/user/.local/lib/python3.9/site-packages/streamlit/legacy_caching/caching.py", line 527, in get_or_create_cached_value
return_value = func(*args, **kwargs)
File "/media/user/Data/streamlit_freecodecamp/app_6_eda_cryptocurrency/app.py", line 68, in load_data
coins[str(i['id'])] = i['slug']
nucleotide encoding field is specified without a type; the type cannot be inferred because it does not match any column in the data. this error kept showing for the barchart part!!
When plotting the 2 SHAP figures, the figures appear, but the following warning also appears.
st.header('Feature Importance')
plt.title('Feature importance based on SHAP values')
shap.summary_plot(shap_values, X)
st.pyplot(bbox_inches = 'tight')
st.write('----')
plt.title('Feature importance based on SHAP values (Bar)')
shap.summary_plot(shap_values, X, plot_type = 'bar')
st.pyplot(bbox_inches = 'tight')
PyplotGlobalUseWarning: You are calling st.pyplot() without any arguments. After December 1st, 2020, we will remove the ability to do this as it requires the use of Matplotlib's global figure object, which is not thread-safe.
The temporary solution is to configure the streamlit option:
st.set_option('deprecation.showPyplotGlobalUse', False)
However, is there a solution that does not require disabling deprecation warnings?
For some of the prior examples, like the basketball_app.py, it was easy to determine what to pass as the fig:
st.pyplot(f)
For this streamlit dashboard, which incorporates the SHAP library, what can be passed in as the <fig>
in line 81 & 86: st.pyplot(<fig?>, bbox_inches = 'tight')
?
Version Reference:
python - 3.10.0
matplotlib - 3.5.1
streamlit - 1.5.1
scikit-learn - 1.0.2
shap - 0.39.0
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
I am having trouble replicating the code and keep getting this error. The code is below
import streamlit as st
import pandas as pd
import base64
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
st.title('NBA Player Stats Explorer')
st.markdown("""
This app performs simple webscraping of NBA player stats data!
st.sidebar.header('User Input Features')
selected_year = st.sidebar.selectbox('Year', list(reversed(range(1950,2020))))
#year = 2020
@st.cache
def load_data(year):
url = "https://www.basketball-reference.com/leagues/NBA_" + str(year) + "_per_game.html"
html = pd.read_html(url, header = 0)
df = html[0]
raw = df.drop(df[df.Age == 'Age'].index) # Deletes repeating headers in content
raw = raw.fillna(0)
playerstats = raw.drop(['Rk'], axis=1)
playerstats.columns = [i.replace('%', '_percent') for i in playerstats.columns]
for i in playerstats.filter(regex='percent').columns:
for i in playerstats.filter(regex='%').columns:
playerstats[i] = playerstats[i].astype(float)
return playerstats
playerstats = load_data(selected_year)
sorted_unique_team = sorted(playerstats.Tm.unique())
selected_team = st.sidebar.multiselect('Team', sorted_unique_team, sorted_unique_team)
unique_pos = ['C','PF','SF','PG','SG']
selected_pos = st.sidebar.multiselect('Position', unique_pos, unique_pos)
df_selected_team = playerstats[(playerstats.Tm.isin(selected_team)) & (playerstats.Pos.isin(selected_pos))]
st.header('Display Player Stats of Selected Team(s)')
st.write('Data Dimension: ' + str(df_selected_team.shape[0]) + ' rows and ' + str(df_selected_team.shape[1]) + ' columns.')
st.dataframe(df_selected_team)
def filedownload(df):
csv = df.to_csv(index=False)
b64 = base64.b64encode(csv.encode()).decode() # strings <-> bytes conversions
href = f'Download CSV File'
return href
st.markdown(filedownload(df_selected_team), unsafe_allow_html=True)
if st.button('Intercorrelation Heatmap'):
st.header('Intercorrelation Matrix Heatmap')
df_selected_team.to_csv('output.csv',index=False)
df = pd.read_csv('output.csv')
corr = df.corr()
mask = np.zeros_like(corr)
mask[np.triu_indices_from(mask)] = True
with sns.axes_style("white"):
f, ax = plt.subplots(figsize=(7, 5))
ax = sns.heatmap(corr, mask=mask, vmax=1, square=True)
st.pyplot()
im getting this error while running the code of streamlit repo (iris classifier )
please tell me why is this throwing up?
UserWarning: X has feature names, but RandomForestClassifier was fitted without feature names
2021-07-25 15:14:41.237 Traceback (most recent call last):
File "/Users/viharieyunni/opt/anaconda3/envs/datasci-env/lib/python3.9/site-packages/streamlit/caching.py", line 509, in get_or_create_cached_value
return_value = _read_from_cache(
File "/Users/viharieyunni/opt/anaconda3/envs/datasci-env/lib/python3.9/site-packages/streamlit/caching.py", line 308, in _read_from_cache
raise e
File "/Users/viharieyunni/opt/anaconda3/envs/datasci-env/lib/python3.9/site-packages/streamlit/caching.py", line 293, in _read_from_cache
return _read_from_mem_cache(
File "/Users/viharieyunni/opt/anaconda3/envs/datasci-env/lib/python3.9/site-packages/streamlit/caching.py", line 212, in _read_from_mem_cache
raise CacheKeyNotFoundError("Key not found in mem cache")
streamlit.caching.CacheKeyNotFoundError: Key not found in mem cache
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/viharieyunni/opt/anaconda3/envs/datasci-env/lib/python3.9/site-packages/streamlit/script_runner.py", line 350, in _run_script
exec(code, module.dict)
File "/Users/viharieyunni/Desktop/dswebapps/EDACrypto_main.py", line 96, in
df = load_data()
File "/Users/viharieyunni/opt/anaconda3/envs/datasci-env/lib/python3.9/site-packages/streamlit/caching.py", line 543, in wrapped_func
return get_or_create_cached_value()
File "/Users/viharieyunni/opt/anaconda3/envs/datasci-env/lib/python3.9/site-packages/streamlit/caching.py", line 527, in get_or_create_cached_value
return_value = func(*args, **kwargs)
File "/Users/viharieyunni/Desktop/dswebapps/EDACrypto_main.py", line 79, in load_data
percent_change_1h.append(i['quote'][currency_price_unit]['percent_change_1h'])
KeyError: 'percent_change_1h'
There is 'percent_change_1h' value yet it is throwing an error
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.