Penguni commited on
Commit
5a0a701
1 Parent(s): 5d3ce14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -67
app.py CHANGED
@@ -1,73 +1,24 @@
1
- import sqlite3
2
  import streamlit as st
 
 
3
 
4
- # Function to query the database and get the number of movies
5
- def get_movie_count():
6
- # Connect to the SQLite database
7
- conn = sqlite3.connect('imdb.db')
8
- cursor = conn.cursor()
9
 
10
- # Query to count the number of movies
11
- cursor.execute('SELECT COUNT(*) FROM title_basics WHERE titleType = "movie"')
12
- movie_count = cursor.fetchone()[0]
 
13
 
14
- # Close the connection
15
- conn.close()
16
 
17
- return movie_count
 
18
 
19
- # Function to query the database and get the number of unique languages
20
- def get_language_count():
21
- # Connect to the SQLite database
22
- conn = sqlite3.connect('imdb.db')
23
- cursor = conn.cursor()
24
-
25
- # Query to count the number of unique languages
26
- cursor.execute('SELECT COUNT(DISTINCT language) FROM title_basics')
27
- language_count = cursor.fetchone()[0]
28
-
29
- # Close the connection
30
- conn.close()
31
-
32
- return language_count
33
-
34
- # Function to query the database and get the number of unique countries
35
- def get_country_count():
36
- # Connect to the SQLite database
37
- conn = sqlite3.connect('imdb.db')
38
- cursor = conn.cursor()
39
-
40
- # Query to count the number of unique countries
41
- cursor.execute('SELECT COUNT(DISTINCT country) FROM title_basics')
42
- country_count = cursor.fetchone()[0]
43
-
44
- # Close the connection
45
- conn.close()
46
-
47
- return country_count
48
-
49
- # Main Streamlit app
50
- def main():
51
- # Title
52
- st.title('IMDb Dataset Statistics')
53
-
54
- # Create a 3-column layout using Streamlit
55
- col1, col2, col3 = st.columns(3)
56
-
57
- # Column 1: Number of Movies
58
- with col1:
59
- st.markdown('<span class="material-icons-outlined" style="font-size: 48px;">movie</span>', unsafe_allow_html=True)
60
- st.markdown(f'<div style="text-align: center; font-size: 24px;">Movies: <strong>{get_movie_count()}</strong></div>', unsafe_allow_html=True)
61
-
62
- # Column 2: Number of Languages
63
- with col2:
64
- st.markdown('<span class="material-icons-outlined" style="font-size: 48px;">language</span>', unsafe_allow_html=True)
65
- st.markdown(f'<div style="text-align: center; font-size: 24px;">Languages: <strong>{get_language_count()}</strong></div>', unsafe_allow_html=True)
66
-
67
- # Column 3: Number of Countries
68
- with col3:
69
- st.markdown('<span class="material-icons-outlined" style="font-size: 48px;">public</span>', unsafe_allow_html=True)
70
- st.markdown(f'<div style="text-align: center; font-size: 24px;">Countries: <strong>{get_country_count()}</strong></div>', unsafe_allow_html=True)
71
-
72
- if __name__ == '__main__':
73
- main()
 
 
1
  import streamlit as st
2
+ import pandas as pd
3
+ import plotly.express as px
4
 
5
+ # Load your dataframes
6
+ df1= pd.read_csv('/content/series_after_cleaning.csv')
7
+ df2= pd.read_csv('/content/movie_after_cleaning.csv')
 
 
8
 
9
+ # Function to generate treemap
10
+ def create_treemap(df, title):
11
+ fig = px.treemap(df, path=['parentalguide'], title=title)
12
+ return fig
13
 
14
+ # Streamlit app
15
+ st.title('Parental Guide Treemaps')
16
 
17
+ # Add buttons to switch between dataframes
18
+ option = st.selectbox('Select DataFrame', ['DataFrame 1', 'DataFrame 2'])
19
 
20
+ # Display the corresponding treemap based on the selected dataframe
21
+ if option == 'DataFrame 1':
22
+ st.plotly_chart(create_treemap(df1, 'Parental Guide - DataFrame 1'))
23
+ else:
24
+ st.plotly_chart(create_treemap(df2, 'Parental Guide - DataFrame 2'))