-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53b1982
commit 664c301
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import streamlit as st | ||
import io | ||
import pandas as pd | ||
import seaborn as sns | ||
from pathlib import Path | ||
|
||
|
||
st.title("Pair Plot") | ||
|
||
st.markdown(""" | ||
Application to explore the numerical columns as a pair plot. | ||
""") | ||
|
||
root = Path("datasets") | ||
root.mkdir(exist_ok=True) | ||
|
||
def get_categorical_columns(df): | ||
return [c for c in df.select_dtypes(include='object') if df[c].nunique() <= 10] | ||
|
||
def pairplot(uploaded_file): | ||
path = root.joinpath(uploaded_file.name) | ||
path.write_bytes(uploaded_file.read()) | ||
df = pd.read_csv(path) | ||
|
||
cats = ["None"] + get_categorical_columns(df) | ||
hue = st.selectbox("Color By", options=cats) | ||
if hue == "None": | ||
hue = None | ||
|
||
ax = sns.pairplot(df, hue=hue) | ||
st.pyplot(ax.figure) | ||
|
||
|
||
st.header("Select a Dataset") | ||
uploaded_file = st.file_uploader("Select Dataset", "csv") | ||
|
||
if uploaded_file: | ||
st.header("Pair Plot") | ||
pairplot(uploaded_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
seaborn | ||
streamlit |