So im trying to use describe() function to my dataframe to find some descriptive statistics of the data in my Streamlit webpage. Here is the head of the dataframe:
st.write(superstore_data.describe(include='all'))
But it returns with an exception like this:
StreamlitAPIException: ("Could not convert 'CA-2018-100111' with type str: ,tried to convert to int64", 'Conversion failed for column Order ID with type object')
I tried describe function directly (not using Streamlit), and it works:
import pandas as pd
superstore_data = pd.read_csv('data/superstore.csv')
superstore_data.describe(include='all')
Is there any details i missed from streamlit? Why Streamlit API can’t use pandas describe function?
i already tried to store it in dataframe first and then write it with st.swrite (tried st.table too), it prints the same error. Here i share the datasets Superstore Sales Dataset | Kaggle
This is the full code:
import streamlit as st
import time
import numpy as np
import pandas as pd
st.set_page_config(page_title="About Datasets", page_icon="đź•®")
st.title("About Datasets")
st.subheader("1. Superstore Sale Datasets, didapat dari Kaggle [disini](https://www.kaggle.com/datasets/rohitsahoo/sales-forecasting)")
superstore_data = pd.read_csv('data/superstore.csv')
st.write('preview:')
st.write(superstore_data.head())
columns_length=len(superstore_data.columns)
rows_length=len(superstore_data)
st.write('Jumlah kolom:', columns_length)
st.write('Jumlah baris:', rows_length)
st.write('#### Cek Nilai null')
st.write(superstore_data.isnull().sum(), 'Terdapat nilai null pada kolom Postal Code sebanyak 11 baris. Dikarenakan field/kolom postal code tidak digunakan pada analisis dan juga sulit untuk mengisinya karena kekurangan informasi, maka nilai null tersebut diabaikan')
# null = superstore_data[superstore_data.isnull().any(axis=1)]
# st.write(null)
st.write('#### Cek Data Duplikat')
st.write('terdapat', superstore_data.duplicated().sum(), 'data duplikat')
st.write('#### Descriptive Statistics')
df = superstore_data.describe(include='all')
st.write(df)
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.