Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
suyashi29
GitHub Repository: suyashi29/python-su
Path: blob/master/Gen AI for Intelligent Data Handling/2.1 Auto Dashboarding using Python.ipynb
3370 views
Kernel: Python 3 (ipykernel)
  • numpy==1.26.4

  • pandas==2.2.2

  • matplotlib==3.7.5

  • seaborn==0.13.2

  • scikit-learn==1.5.1

  • autoviz==0.1.905

  • dtale==3.13.0

  • streamlit==1.38.0

  • plotly==5.24.1

  • transformers==4.44.2

!conda create -n genai_demo python=3.10 -y !conda activate genai_demo !pip install -r requirements.txt
pip install faker
Requirement already satisfied: faker in c:\users\suyashi144893\appdata\local\anaconda3\lib\site-packages (37.8.0)Note: you may need to restart the kernel to use updated packages. Requirement already satisfied: tzdata in c:\users\suyashi144893\appdata\local\anaconda3\lib\site-packages (from faker) (2023.3)
pip install streamlit
!streamlit run streamlit_app.py --server.port 8502 --server.headless true
%%writefile streamlit_app.py import streamlit as st import pandas as pd import numpy as np # Title st.title("📊 Auto Dashboard Demo") # Generate random dataset df = pd.DataFrame({ "age": np.random.randint(20, 60, 50), "salary": np.random.randint(30000, 120000, 50), "department": np.random.choice(["HR", "Finance", "IT", "Marketing"], 50) }) # Show dataframe st.subheader("Dataset") st.dataframe(df) # Basic plots st.subheader("Salary Distribution") st.bar_chart(df["salary"]) st.subheader("Department Count") st.bar_chart(df["department"].value_counts())
Overwriting streamlit_app.py
## !cp streamlit_app.py streamlit_app_v1.py # Linux/Mac # OR for Windows: !copy streamlit_app.py streamlit_app_v1.py
1 file(s) copied.

A fully interactive demo with multiple visuals and automatic data description. This will make it feel like a real intelligent data handling dashboard.

%%writefile streamlit_app.py import streamlit as st import pandas as pd import numpy as np import plotly.express as px st.set_page_config(page_title="AI Data Handling Dashboard", layout="wide") st.title("📊 Intelligent Data Handling Dashboard") # ------------------------------- # Generate Random Dataset # ------------------------------- np.random.seed(42) df = pd.DataFrame({ "CustomerID": [f"CUST{i:03d}" for i in range(1, 101)], "Age": np.random.randint(18, 65, 100), "Salary": np.random.randint(30000, 120000, 100), "Department": np.random.choice(["HR", "Finance", "IT", "Marketing"], 100), "PurchaseAmount": np.round(np.random.uniform(50, 2000, 100), 2) }) # ------------------------------- # Dataset Info & Description # ------------------------------- st.subheader("🔍 Dataset Overview") st.write("Shape:", df.shape) st.write("Columns:", df.columns.tolist()) st.write("Data Types:") st.write(df.dtypes) st.write("Missing Values:") st.write(df.isnull().sum()) st.subheader("📊 Statistical Summary") st.dataframe(df.describe().round(2)) # ------------------------------- # Interactive Filters # ------------------------------- st.subheader("⚡ Interactive Filters") department_filter = st.multiselect("Select Department(s):", options=df["Department"].unique(), default=df["Department"].unique()) filtered_df = df[df["Department"].isin(department_filter)] st.write(f"Filtered Data ({len(filtered_df)} rows)") st.dataframe(filtered_df.head(10)) # ------------------------------- # Visualizations # ------------------------------- st.subheader("📈 Visualizations") col1, col2 = st.columns(2) with col1: st.write("**Age Distribution**") fig_age = px.histogram(filtered_df, x="Age", nbins=10, title="Age Distribution") st.plotly_chart(fig_age, use_container_width=True) with col2: st.write("**Salary Distribution**") fig_salary = px.histogram(filtered_df, x="Salary", nbins=10, title="Salary Distribution") st.plotly_chart(fig_salary, use_container_width=True) st.write("**Purchase Amount vs Age**") fig_scatter = px.scatter(filtered_df, x="Age", y="PurchaseAmount", color="Department", hover_data=["CustomerID"]) st.plotly_chart(fig_scatter, use_container_width=True) df_count = filtered_df["Department"].value_counts().reset_index() df_count.columns = ["Department", "Count"] fig_count = px.bar( df_count, x="Department", y="Count", labels={"Department": "Department", "Count": "Number of Employees"}, title="Department Count" ) st.plotly_chart(fig_count, use_container_width=True) st.write("**Salary Boxplot by Department**") fig_box = px.box(filtered_df, x="Department", y="Salary", color="Department") st.plotly_chart(fig_box, use_container_width=True)
Overwriting streamlit_app.py
!streamlit run streamlit_app.py --server.port 8502 --server.headless true
Collecting usage statistics. To deactivate, set browser.gatherUsageStats to false.
2025-09-18 14:54:51.823 Port 8502 is already in use
!streamlit run streamlit_app.py --server.port 8502 --server.headless False