Quetiento commited on
Commit
416e8ab
1 Parent(s): f9d0531

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -42
app.py CHANGED
@@ -1,43 +1,43 @@
1
- import streamlit as st
2
- import pandas as pd
3
- import matplotlib.pyplot as plt
4
- import seaborn as sns
5
-
6
- # read the dataset
7
- df = pd.read_csv('diamonds.csv')
8
-
9
- st.title('Diamond APP sorting festivity. Noted by Dimitri')
10
-
11
- df = df.drop(["Unnamed: 0"], axis=1)
12
-
13
- #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.
14
- df = df.drop(df[df["x"]==0].index)
15
- df = df.drop(df[df["y"]==0].index)
16
- df = df.drop(df[df["z"]==0].index)
17
- st.image('diamonds.jpg')
18
- st.write(f"the price range is {326} to {18823}")
19
- # users set the price range
20
- 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()))
21
- 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()))
22
-
23
- #users select
24
- selected_cuts = st.multiselect('choosing cut', df['cut'].unique())
25
- selected_cuts = st.multiselect('choosing color', df['color'].unique())
26
- selected_cuts = st.multiselect('choosing clarity', df['clarity'].unique())
27
- selected_cuts = st.multiselect('choosing carat', df['carat'].unique())
28
-
29
-
30
- # select the diamonds
31
- filtered_diamonds = df[(df['price'] >= min_price) & (df['price'] <= max_price)]
32
-
33
- # show the results
34
- if not filtered_diamonds.empty:
35
- st.write(f"find {len(filtered_diamonds)} diamonds for you.")
36
- st.dataframe(filtered_diamonds)
37
- # Create a scatterplot based on the selected criteria
38
- fig, ax = plt.subplots()
39
- sns.scatterplot(x='carat', y='price', data=filtered_diamonds, ax=ax)
40
- ax.set_title('Prices by Carat')
41
- st.pyplot(fig)
42
- else:
43
  st.write("No diamonds fit you")
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import matplotlib.pyplot as plt
4
+ import seaborn as sns
5
+
6
+ # read the dataset
7
+ df = pd.read_csv('diamonds.csv')
8
+
9
+ st.title('Diamond APP sorting festivity')
10
+
11
+ df = df.drop(["Unnamed: 0"], axis=1)
12
+
13
+ #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.
14
+ df = df.drop(df[df["x"]==0].index)
15
+ df = df.drop(df[df["y"]==0].index)
16
+ df = df.drop(df[df["z"]==0].index)
17
+ st.image('diamonds.jpg')
18
+ st.write(f"the price range is {326} to {18823}")
19
+ # users set the price range
20
+ 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()))
21
+ 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()))
22
+
23
+ #users select
24
+ selected_cuts = st.multiselect('choosing cut', df['cut'].unique())
25
+ selected_cuts = st.multiselect('choosing color', df['color'].unique())
26
+ selected_cuts = st.multiselect('choosing clarity', df['clarity'].unique())
27
+ selected_cuts = st.multiselect('choosing carat', df['carat'].unique())
28
+
29
+
30
+ # select the diamonds
31
+ filtered_diamonds = df[(df['price'] >= min_price) & (df['price'] <= max_price)]
32
+
33
+ # show the results
34
+ if not filtered_diamonds.empty:
35
+ st.write(f"find {len(filtered_diamonds)} diamonds for you.")
36
+ st.dataframe(filtered_diamonds)
37
+ # Create a scatterplot based on the selected criteria
38
+ fig, ax = plt.subplots()
39
+ sns.scatterplot(x='carat', y='price', data=filtered_diamonds, ax=ax)
40
+ ax.set_title('Prices by Carat')
41
+ st.pyplot(fig)
42
+ else:
43
  st.write("No diamonds fit you")