Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
from pandas_profiling import ProfileReport
|
4 |
+
|
5 |
+
st.set_page_config(page_title="File Upload and Profiling", layout="wide")
|
6 |
+
|
7 |
+
st.title("File Upload and Profiling")
|
8 |
+
|
9 |
+
uploaded_file = st.file_uploader("Upload a CSV file", type="csv")
|
10 |
+
|
11 |
+
if uploaded_file is not None:
|
12 |
+
# Load the data using pandas
|
13 |
+
df = pd.read_csv(uploaded_file)
|
14 |
+
|
15 |
+
# Generate the pandas profiling report
|
16 |
+
profile = ProfileReport(df, explorative=True)
|
17 |
+
|
18 |
+
# Display the pandas profiling report using streamlit
|
19 |
+
st.header("Data Profiling Report")
|
20 |
+
st.write(profile.to_html(), unsafe_allow_html=True)
|
21 |
+
|
22 |
+
# Display word statistics for each categorical string column
|
23 |
+
cat_cols = df.select_dtypes(include='object').columns
|
24 |
+
st.header("Word Statistics for Categorical Columns")
|
25 |
+
for col in cat_cols:
|
26 |
+
st.subheader(col)
|
27 |
+
word_count = df[col].str.split().apply(len).value_counts().sort_index()
|
28 |
+
st.bar_chart(word_count)
|
29 |
+
|
30 |
+
# Grouped count by each feature
|
31 |
+
num_cols = df.select_dtypes(include=['float', 'int']).columns
|
32 |
+
st.header("Grouped Count by Each Feature")
|
33 |
+
for col in num_cols:
|
34 |
+
st.subheader(col)
|
35 |
+
count_by_feature = df.groupby(col).size().reset_index(name='count')
|
36 |
+
st.bar_chart(count_by_feature)
|