Spaces:
Runtime error
Runtime error
| #pass="Leswhdc2023$!" | |
| import streamlit as st | |
| import pandas as pd | |
| import plotly.express as px | |
| import cx_Oracle as ora | |
| import pandas as pd | |
| from pandas_profiling import ProfileReport | |
| st.title("File Upload and Profiling") | |
| # uploaded_file = st.file_uploader("Upload a CSV file", type="csv") | |
| # RunProfiler=False | |
| # if uploaded_file is not None: | |
| # if RunProfiler: | |
| # # Load the data using pandas | |
| # df = pd.read_csv(uploaded_file) | |
| # # Generate the pandas profiling report | |
| # profile = ProfileReport(df, explorative=True) | |
| # # Display the pandas profiling report using streamlit | |
| # st.header("Data Profiling Report") | |
| # st.write(profile.to_html(), unsafe_allow_html=True) | |
| # # Display word statistics for each categorical string column | |
| # cat_cols = df.select_dtypes(include='object').columns | |
| # st.header("Word Statistics for Categorical Columns") | |
| # for col in cat_cols: | |
| # st.subheader(col) | |
| # word_count = df[col].str.split().apply(len).value_counts().sort_index() | |
| # st.bar_chart(word_count) | |
| # # Grouped count by each feature | |
| # num_cols = df.select_dtypes(include=['float', 'int']).columns | |
| # st.header("Grouped Count by Each Feature") | |
| # for col in num_cols: | |
| # st.subheader(col) | |
| # count_by_feature = df.groupby(col).size().reset_index(name='count') | |
| # st.bar_chart(count_by_feature) | |
| # Upload a CSV dataset | |
| uploaded_file = st.file_uploader("Upload your dataset", type=["csv"]) | |
| if uploaded_file is not None: | |
| # Load the dataset and display the first 5 rows | |
| df = pd.read_csv(uploaded_file) | |
| st.dataframe(df.head()) | |
| # Generate a treemap or sunburst plot based on data types | |
| numerical_cols = df.select_dtypes(include=["float", "int"]).columns | |
| categorical_cols = df.select_dtypes(include=["object"]).columns | |
| fig = px.treemap(df, path=categorical_cols) | |
| st.plotly_chart(fig) | |
| # if len(numerical_cols) >= 2: | |
| # fig = px.scatter_matrix(df, dimensions=numerical_cols) | |
| # st.plotly_chart(fig) | |
| # elif len(categorical_cols) >= 2: | |
| # fig = px.treemap(df, path=categorical_cols) | |
| # st.plotly_chart(fig) | |
| # else: | |
| # fig = px.sunburst(df, path=categorical_cols + numerical_cols) | |
| # st.plotly_chart(fig) | |