File size: 1,739 Bytes
f9d0531
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

# read the dataset
df = pd.read_csv('diamonds.csv')

st.title('Diamond APP sorting festivity. Noted by Dimitri')

df = df.drop(["Unnamed: 0"], axis=1)

#Potential diamonds with a impossible dimensions are dropped, for example a diamond that has a 0 in x, y or z should not be possible.
df = df.drop(df[df["x"]==0].index)
df = df.drop(df[df["y"]==0].index)
df = df.drop(df[df["z"]==0].index)
st.image('diamonds.jpg')
st.write(f"the price range is {326} to {18823}")
# users set the price range
min_price = st.number_input('Input minimum price', min_value=int(df['price'].min()), max_value=int(df['price'].max()), value=int(df['price'].min()))
max_price = st.number_input('Input maximum price', min_value=int(df['price'].min()), max_value=int(df['price'].max()), value=int(df['price'].max()))

#users select
selected_cuts = st.multiselect('choosing cut', df['cut'].unique())
selected_cuts = st.multiselect('choosing color', df['color'].unique())
selected_cuts = st.multiselect('choosing clarity', df['clarity'].unique())
selected_cuts = st.multiselect('choosing carat', df['carat'].unique())


# select the diamonds
filtered_diamonds = df[(df['price'] >= min_price) & (df['price'] <= max_price)]

# show the results
if not filtered_diamonds.empty:
    st.write(f"find {len(filtered_diamonds)} diamonds for you.")
    st.dataframe(filtered_diamonds)
# Create a scatterplot based on the selected criteria
    fig, ax = plt.subplots()
    sns.scatterplot(x='carat', y='price', data=filtered_diamonds, ax=ax)
    ax.set_title('Prices by Carat')
    st.pyplot(fig)
else:
    st.write("No diamonds fit you")