Skip to content

Commit

Permalink
Added pairplot
Browse files Browse the repository at this point in the history
  • Loading branch information
anandology committed Aug 5, 2023
1 parent 53b1982 commit 664c301
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
39 changes: 39 additions & 0 deletions pairplot/pairplot.py
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)
2 changes: 2 additions & 0 deletions pairplot/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
seaborn
streamlit

0 comments on commit 664c301

Please sign in to comment.