shilpabanerjee commited on
Commit
bb7a8c1
·
1 Parent(s): 76545c3

Upload 3 files

Browse files
Files changed (3) hide show
  1. Data/layoffs_data.csv +0 -0
  2. app.py +104 -0
  3. requirements.txt +64 -0
Data/layoffs_data.csv ADDED
The diff for this file is too large to render. See raw diff
 
app.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import seaborn as sns
4
+ import matplotlib.pyplot as plt
5
+ import plotly.express as px
6
+ from wordcloud import WordCloud
7
+
8
+ # Set page title
9
+ st.set_page_config(page_title='Layoffs Data Visualization')
10
+
11
+ # Load the CSV file
12
+ @st.cache_data # Caching the data for improved performance
13
+ def load_data(file_path):
14
+ data = pd.read_csv(file_path)
15
+ return data
16
+
17
+ # Main function
18
+ def main():
19
+ # Page title and description
20
+ st.title("Layoffs Data Visualization")
21
+ st.write("Explore and visualize layoffs data")
22
+
23
+ # Load the data
24
+ data = load_data("Data/layoffs_data.csv")
25
+
26
+ # Sidebar options
27
+ st.sidebar.title("Options")
28
+ selected_option = st.sidebar.selectbox("Select an option", ("Data Preview", "Unique Industries",
29
+ "Layoffs Count by Company",
30
+ "Layoffs Count by Country",
31
+ "Bar plot of layoffs by industry",
32
+ "Line plot of layoffs over time",
33
+ "Word Cloud of Industries",
34
+ "Histogram of Laid Off Counts",
35
+ "Scatter Plot",
36
+ "List of Companies and Laid Off Employees"))
37
+
38
+ # Data exploration
39
+ if selected_option == "Data Preview":
40
+ st.subheader("Data Preview")
41
+ num_rows = st.number_input("Number of rows to display", min_value=1, value=len(data))
42
+ st.dataframe(data.head(num_rows))
43
+
44
+ elif selected_option == "Unique Industries":
45
+ st.subheader("Unique Industries")
46
+ unique_industries = data['Industry'].unique()
47
+ st.write(unique_industries)
48
+
49
+ elif selected_option == "Layoffs Count by Company":
50
+ st.subheader("Layoffs Count by Company")
51
+ company_counts = data['Company'].value_counts()
52
+ st.write(company_counts)
53
+
54
+ elif selected_option == "Layoffs Count by Country":
55
+ st.subheader("Layoffs Count by Country")
56
+ country_counts = data['Country'].value_counts()
57
+ st.write(country_counts)
58
+
59
+ # Data visualization
60
+ elif selected_option == "Bar plot of layoffs by industry":
61
+ st.subheader("Bar plot of layoffs by industry")
62
+ industry_counts = data['Industry'].value_counts()
63
+ fig, ax = plt.subplots(figsize=(10, 6))
64
+ sns.barplot(x=industry_counts.index, y=industry_counts.values, ax=ax)
65
+ ax.set_xticklabels(industry_counts.index, rotation=90)
66
+ st.pyplot(fig)
67
+
68
+ elif selected_option == "Line plot of layoffs over time":
69
+ st.subheader("Line plot of layoffs over time")
70
+ data['Date'] = pd.to_datetime(data['Date'])
71
+ layoffs_over_time = data.groupby('Date').sum()['Laid_Off_Count']
72
+ fig, ax = plt.subplots(figsize=(10, 6))
73
+ sns.lineplot(x=layoffs_over_time.index, y=layoffs_over_time.values, ax=ax)
74
+ ax.set_xlabel("Date")
75
+ ax.set_ylabel("Layoffs Count")
76
+ st.pyplot(fig)
77
+
78
+ elif selected_option == "Word Cloud of Industries":
79
+ st.subheader("Word Cloud of Industries")
80
+ industry_text = ' '.join(data['Industry'].dropna().values.tolist())
81
+ wordcloud = WordCloud(width=800, height=400).generate(industry_text)
82
+ plt.figure(figsize=(10, 6))
83
+ plt.imshow(wordcloud, interpolation='bilinear')
84
+ plt.axis("off")
85
+ st.pyplot(plt)
86
+
87
+ elif selected_option == "Histogram of Laid Off Counts":
88
+ st.subheader("Histogram of Laid Off Counts")
89
+ fig, ax = plt.subplots(figsize=(10, 6))
90
+ sns.histplot(data['Laid_Off_Count'], kde=True, ax=ax)
91
+ st.pyplot(fig)
92
+
93
+ elif selected_option == "Scatter Plot":
94
+ st.subheader("Scatter Plot")
95
+ fig = px.scatter(data, x='Funds_Raised', y='Laid_Off_Count', color='Stage')
96
+ st.plotly_chart(fig)
97
+
98
+ elif selected_option == "List of Companies and Laid Off Employees":
99
+ st.subheader("List of Companies and Laid Off Employees")
100
+ company_employees = data.groupby('Company').sum()['Laid_Off_Count'].reset_index()
101
+ st.dataframe(company_employees)
102
+
103
+ if __name__ == '__main__':
104
+ main()
requirements.txt ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ altair==5.0.1
2
+ attrs==23.1.0
3
+ blinker==1.6.2
4
+ branca==0.6.0
5
+ cachetools==5.3.1
6
+ certifi==2023.5.7
7
+ charset-normalizer==3.1.0
8
+ click==8.1.3
9
+ colorama==0.4.6
10
+ contourpy==1.0.7
11
+ cycler==0.11.0
12
+ decorator==5.1.1
13
+ folium==0.14.0
14
+ fonttools==4.39.4
15
+ gitdb==4.0.10
16
+ GitPython==3.1.31
17
+ idna==3.4
18
+ importlib-metadata==6.6.0
19
+ Jinja2==3.1.2
20
+ joblib==1.2.0
21
+ jsonschema==4.17.3
22
+ kiwisolver==1.4.4
23
+ markdown-it-py==2.2.0
24
+ MarkupSafe==2.1.3
25
+ matplotlib==3.7.1
26
+ mdurl==0.1.2
27
+ nltk==3.8.1
28
+ numpy==1.24.3
29
+ packaging==23.1
30
+ pandas==2.0.2
31
+ Pillow==9.5.0
32
+ plotly==5.15.0
33
+ protobuf==4.23.2
34
+ pyarrow==12.0.0
35
+ pydeck==0.8.1b0
36
+ Pygments==2.15.1
37
+ Pympler==1.0.1
38
+ pyparsing==3.0.9
39
+ pyrsistent==0.19.3
40
+ python-dateutil==2.8.2
41
+ pytz==2023.3
42
+ pytz-deprecation-shim==0.1.0.post0
43
+ regex==2023.6.3
44
+ requests==2.31.0
45
+ rich==13.4.1
46
+ seaborn==0.12.2
47
+ six==1.16.0
48
+ smmap==5.0.0
49
+ streamlit==1.23.1
50
+ streamlit-folium==0.12.0
51
+ tenacity==8.2.2
52
+ textblob==0.17.1
53
+ toml==0.10.2
54
+ toolz==0.12.0
55
+ tornado==6.3.2
56
+ tqdm==4.65.0
57
+ typing_extensions==4.6.3
58
+ tzdata==2023.3
59
+ tzlocal==4.3
60
+ urllib3==2.0.3
61
+ validators==0.20.0
62
+ watchdog==3.0.0
63
+ wordcloud==1.9.2
64
+ zipp==3.15.0