-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
60 lines (49 loc) · 2.02 KB
/
main.py
File metadata and controls
60 lines (49 loc) · 2.02 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from preswald import connect, get_df, table, text, plotly
import pandas as pd
import plotly.express as px
# Connect to Preswald
connect()
# Load dataset
df = get_df("Indian_startups_funding")
# Clean column names
df.columns = df.columns.str.strip().str.replace(' ', '_').str.replace(r'[^\w\s]', '', regex=True)
# Convert data types
df['amount'] = pd.to_numeric(df['amount'], errors='coerce')
df['year'] = pd.to_numeric(df['year'], errors='coerce')
df = df.dropna(subset=['amount', 'year'])
# Filter settings
filter_start_year = 2015
filter_end_year = 2021
filter_industry = None # Example: 'Technology' or None for all industries
# Filter data
filtered = df[(df['year'] >= filter_start_year) & (df['year'] <= filter_end_year)]
if filter_industry:
filtered = filtered[filtered['vertical'] == filter_industry]
# Display header
text("# InnoFund Insights - Startup Funding Dashboard")
text(f"Data from {filter_start_year} to {filter_end_year}" +
(f", Industry: {filter_industry}" if filter_industry else ", All Industries"))
# Sample data
table(filtered.head(10))
# High funding startups
high_funding = filtered[filtered['amount'] > 100]
text("## Startups with Over $100M Funding")
table(high_funding[['startup', 'vertical', 'amount', 'year']])
# Top industries by funding
industry_funding = (filtered.groupby('vertical')['amount']
.sum()
.sort_values(ascending=False)
.reset_index()
.head(10))
fig1 = px.bar(industry_funding, x='vertical', y='amount',
title='Top 10 Industries by Total Funding',
labels={'vertical': 'Industry', 'amount': 'Total Funding (USD)'},
color='amount', color_continuous_scale='Blues')
plotly(fig1)
# Funding over years
funding_by_year = filtered.groupby('year')['amount'].sum().reset_index()
fig2 = px.line(funding_by_year, x='year', y='amount',
title='Funding Over the Years',
labels={'year': 'Year', 'amount': 'Total Funding (USD)'},
markers=True)
plotly(fig2)