-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
73 lines (64 loc) · 2.12 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import io
import numpy as np
import pandas as pd
import streamlit as st
import ydata_profiling
from streamlit_pandas_profiling import st_profile_report
# Web App Title
st.markdown('''
# **The EDA App**
This is the **EDA App** created in Streamlit using the **pandas-profiling** library.
---
''')
# Upload CSV data
with st.sidebar.header('1. Upload your CSV data'):
uploaded_file = st.sidebar.file_uploader("Upload your input CSV file", type=["csv"])
st.sidebar.markdown("""
[Example CSV input file](https://raw.githubusercontent.com/dataprofessor/data/master/delaney_solubility_with_descriptors.csv)
""")
# Pandas Profiling Report
if uploaded_file is not None:
@st.cache
def load_csv():
csv = pd.read_csv(uploaded_file,sep=";",encoding = 'unicode_escape')
return csv
df = load_csv()
# For showing dataframe info
buffer = io.StringIO()
df.info(verbose=True,buf=buffer)
s = buffer.getvalue()
with st.expander("See dataset info"):
st.text(s)
pr = ProfileReport(df, explorative=True)
st.header('**Input DataFrame**')
st.write(df)
st.write('---')
st.header('**Pandas Profiling Report**')
st_profile_report(pr)
else:
st.info('Awaiting for CSV file to be uploaded.')
if st.button('Press to use Example Dataset'):
# Example data
@st.cache
def load_data():
a = pd.DataFrame(
np.random.rand(100, 5),
columns=['a', 'b', 'c', 'd', 'e']
)
return a
df = load_data()
# For showing dataframe info
buffer = io.StringIO()
df.info(verbose=True,buf=buffer)
s = buffer.getvalue()
with st.expander("See dataset info"):
st.text(s)
pr = ProfileReport(df, explorative=True)
st.header('**Input DataFrame**')
st.write(df)
st.write('---')
st.header('**Pandas Profiling Report**')
st_profile_report(pr)
st.markdown('''
**Credit:** App built in **Python** + **Streamlit** adapted by [Roberto](https://github.com/Rchatru). Original idea ([Data Professor](http://youtube.com/dataprofessor))
''')