Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import plotly.express as px | |
| class DashboardBuilder: | |
| def display(self, df): | |
| num_cols = df.select_dtypes("number").columns | |
| if len(num_cols) >= 2: | |
| fig = px.scatter(df, x=num_cols[0], y=num_cols[1], title=f"{num_cols[1]} vs {num_cols[0]}") | |
| st.plotly_chart(fig) | |
| elif len(num_cols) == 1: | |
| fig = px.histogram(df, x=num_cols[0], title=f"Distribution of {num_cols[0]}") | |
| st.plotly_chart(fig) | |
| else: | |
| st.warning("No numeric columns available for visualization.") | |
| st.dataframe(df.head()) | |