Update app.py
Browse files
app.py
CHANGED
@@ -3,23 +3,29 @@ import pandas as pd
|
|
3 |
import matplotlib.pyplot as plt
|
4 |
import seaborn as sns
|
5 |
|
6 |
-
|
7 |
st.title('My first app')
|
8 |
-
st.write("Here's our first
|
9 |
-
|
10 |
|
11 |
df_courses_year = pd.read_csv('udemy_courses_year.csv')
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# Set style for better visuals
|
15 |
sns.set(style="whitegrid")
|
16 |
|
17 |
# Create the plot
|
18 |
plt.figure(figsize=(10, 6))
|
19 |
-
ax = sns.countplot(x='year', data=
|
20 |
ax.set_title('Count of Observations per Year')
|
21 |
ax.set_xlabel('Year')
|
22 |
ax.set_ylabel('Count')
|
23 |
plt.xticks(rotation=45)
|
24 |
|
25 |
-
st.pyplot(plt)
|
|
|
3 |
import matplotlib.pyplot as plt
|
4 |
import seaborn as sns
|
5 |
|
|
|
6 |
st.title('My first app')
|
7 |
+
st.write("Here's our first app with Streamlit")
|
|
|
8 |
|
9 |
df_courses_year = pd.read_csv('udemy_courses_year.csv')
|
10 |
|
11 |
+
# Extract unique years and sort them
|
12 |
+
years = sorted(df_courses_year['year'].unique())
|
13 |
+
|
14 |
+
# Sidebar for selecting year(s)
|
15 |
+
selected_years = st.sidebar.multiselect('Select Year(s)', years, default=years)
|
16 |
+
|
17 |
+
# Filter data based on selected year(s)
|
18 |
+
filtered_data = df_courses_year[df_courses_year['year'].isin(selected_years)]
|
19 |
|
20 |
# Set style for better visuals
|
21 |
sns.set(style="whitegrid")
|
22 |
|
23 |
# Create the plot
|
24 |
plt.figure(figsize=(10, 6))
|
25 |
+
ax = sns.countplot(x='year', data=filtered_data, palette='viridis')
|
26 |
ax.set_title('Count of Observations per Year')
|
27 |
ax.set_xlabel('Year')
|
28 |
ax.set_ylabel('Count')
|
29 |
plt.xticks(rotation=45)
|
30 |
|
31 |
+
st.pyplot(plt)
|