Giter Club home page Giter Club logo

streamlit_freecodecamp's Introduction

streamlit_freecodecamp's People

Contributors

dataprofessor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

streamlit_freecodecamp's Issues

Error for Boston House Regression - Data format

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

IM GETTING ERROR:

URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)>

AttributeError: 'DataFrame' object has no attribute 'close'

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)

5454576

KeyError: 'slug' in App 6 EDA Cryptocurrency

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']

Bar chart

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!!

boston-house-ml-app.py - PyplotGlobalUseWarning: You are calling st.pyplot() without any arguments.

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

App 3 : EDA basket ball

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

ArrowTypeError: ("Expected bytes, got a 'int' object", 'Conversion failed for column FG_percent with type object')

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))))

Web scraping of NBA player stats

#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)

Sidebar - Team selection

sorted_unique_team = sorted(playerstats.Tm.unique())
selected_team = st.sidebar.multiselect('Team', sorted_unique_team, sorted_unique_team)

Sidebar - Position selection

unique_pos = ['C','PF','SF','PG','SG']
selected_pos = st.sidebar.multiselect('Position', unique_pos, unique_pos)

Filtering data

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)

Download NBA player stats data

https://discuss.streamlit.io/t/how-to-download-file-in-streamlit/1806

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)

Heatmap

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()

at the streamlit repo , in the iris classification

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

Issue with EDA Crypto Currency

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.