Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from ydata_profiling import ProfileReport
|
| 4 |
+
|
| 5 |
+
# Set page config (must be the first Streamlit command)
|
| 6 |
+
st.set_page_config(page_title="Dynamic Data Profiling", layout="wide", page_icon="📊")
|
| 7 |
+
|
| 8 |
+
# App title
|
| 9 |
+
st.title("Dynamic Data Profiling with ydata-profiling")
|
| 10 |
+
st.write("Upload your CSV file and get a complete interactive profiling report!")
|
| 11 |
+
|
| 12 |
+
# File uploader widget
|
| 13 |
+
uploaded_file = st.file_uploader("Upload a CSV file", type="csv")
|
| 14 |
+
|
| 15 |
+
if uploaded_file is not None:
|
| 16 |
+
try:
|
| 17 |
+
# Read CSV into DataFrame
|
| 18 |
+
df = pd.read_csv(uploaded_file)
|
| 19 |
+
st.success("File uploaded successfully!")
|
| 20 |
+
|
| 21 |
+
# Generate the profile report
|
| 22 |
+
with st.spinner("Generating profile report..."):
|
| 23 |
+
profile = ProfileReport(df, title="Profiling Report", explorative=True)
|
| 24 |
+
# Get HTML representation of the report
|
| 25 |
+
report_html = profile.to_html()
|
| 26 |
+
|
| 27 |
+
# Display the report in an iframe
|
| 28 |
+
st.components.v1.html(report_html, height=1200, scrolling=True)
|
| 29 |
+
except Exception as e:
|
| 30 |
+
st.error(f"An error occurred: {e}")
|
| 31 |
+
else:
|
| 32 |
+
st.info("Awaiting CSV file upload.")
|