VGreatVig07 commited on
Commit
4edc7ec
·
verified ·
1 Parent(s): 97b9065

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +133 -0
  2. cleaned_vahan.csv +169 -0
  3. cleaned_vahan_final.csv +0 -0
app.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import plotly.express as px
4
+
5
+ # Load datasets
6
+ df_category = pd.read_csv("cleaned_vahan.csv", parse_dates=["Date"])
7
+ df_manufacturer = pd.read_csv("cleaned_vahan_final.csv", parse_dates=["Date"])
8
+
9
+ # Growth calculations function
10
+ def add_growth(df):
11
+ df = df.sort_values(["Category", "Date"])
12
+ df["YoY_Growth"] = df.groupby("Category")["Registrations"].pct_change(periods=12) * 100
13
+ df["QoQ_Growth"] = df.groupby("Category")["Registrations"].pct_change(periods=3) * 100
14
+ return df
15
+
16
+ df_category = add_growth(df_category)
17
+ df_manufacturer = add_growth(df_manufacturer)
18
+
19
+ st.title("Vahan Vehicle Registrations Dashboard")
20
+
21
+ st.sidebar.header("Filters")
22
+
23
+ # ✅ Radio button in sidebar
24
+ view_option = st.sidebar.radio("View Mode", ["Vehicle Type", "Manufacturer"])
25
+
26
+ # Date range filter (common)
27
+ if view_option == "Vehicle Type":
28
+ date_range = st.sidebar.date_input(
29
+ "Select Date Range",
30
+ [df_category["Date"].min(), df_category["Date"].max()]
31
+ )
32
+ else:
33
+ date_range = st.sidebar.date_input(
34
+ "Select Date Range",
35
+ [df_manufacturer["Date"].min(), df_manufacturer["Date"].max()]
36
+ )
37
+
38
+ start_date = pd.to_datetime(date_range[0])
39
+ end_date = pd.to_datetime(date_range[1])
40
+
41
+ filtered_df = pd.DataFrame() # start empty
42
+
43
+ # -------------------------------
44
+ # Vehicle Type Mode
45
+ # -------------------------------
46
+ if view_option == "Vehicle Type":
47
+ categories = st.sidebar.multiselect(
48
+ "Vehicle Types (type to search)",
49
+ options=sorted(df_category["Category"].dropna().astype(str).str.strip().unique()),
50
+ default=[] # empty until user picks
51
+ )
52
+ if categories:
53
+ mask = (df_category["Category"].isin(categories)) & (df_category["Date"].between(start_date, end_date))
54
+ filtered_df = df_category[mask]
55
+
56
+ # -------------------------------
57
+ # Manufacturer Mode
58
+ # -------------------------------
59
+ else:
60
+ manufacturers = sorted(df_manufacturer["Category"].dropna().astype(str).str.strip().unique())
61
+
62
+ selected_manu = st.sidebar.multiselect(
63
+ "Manufacturers (type to search, pick up to 5)",
64
+ options=manufacturers,
65
+ default=[], # empty until user picks
66
+ # If your Streamlit version supports it, uncomment the next line:
67
+ # max_selections=5
68
+ )
69
+
70
+ # Fallback cap if your Streamlit version doesn’t support max_selections
71
+ if len(selected_manu) > 5:
72
+ st.sidebar.warning("Select up to 5 manufacturers. Using the first 5 you picked.")
73
+ selected_manu = selected_manu[:5]
74
+
75
+ if selected_manu:
76
+ mask = (df_manufacturer["Category"].isin(selected_manu)) & (df_manufacturer["Date"].between(start_date, end_date))
77
+ filtered_df = df_manufacturer[mask]
78
+
79
+ # -------------------------------
80
+ # Growth Toggle
81
+ # -------------------------------
82
+ growth_option = st.radio(
83
+ "Select Growth Metric",
84
+ ("None", "Year-over-Year Growth (%)", "Quarter-over-Quarter Growth (%)"),
85
+ horizontal=True
86
+ )
87
+
88
+ # -------------------------------
89
+ # Chart
90
+ # -------------------------------
91
+ if not filtered_df.empty:
92
+ if growth_option == "Year-over-Year Growth (%)":
93
+ fig = px.line(filtered_df, x="Date", y="YoY_Growth", color="Category",
94
+ title="Year-over-Year Growth (%)")
95
+ elif growth_option == "Quarter-over-Quarter Growth (%)":
96
+ fig = px.line(filtered_df, x="Date", y="QoQ_Growth", color="Category",
97
+ title="Quarter-over-Quarter Growth (%)")
98
+ else:
99
+ fig = px.line(filtered_df, x="Date", y="Registrations", color="Category",
100
+ title="Monthly Vehicle Registrations")
101
+ st.plotly_chart(fig, use_container_width=True)
102
+
103
+ st.markdown("---") # separator
104
+
105
+ st.subheader("📌 Key Insights")
106
+
107
+ # Total registrations
108
+ total_reg = filtered_df["Registrations"].sum()
109
+
110
+ # Group by Category/Manufacturer for rankings
111
+ grouped = filtered_df.groupby("Category")["Registrations"].sum().reset_index()
112
+
113
+ # Best performer
114
+ best = grouped.loc[grouped["Registrations"].idxmax()]
115
+ best_cat, best_val = best["Category"], best["Registrations"]
116
+
117
+ # Worst performer
118
+ worst = grouped.loc[grouped["Registrations"].idxmin()]
119
+ worst_cat, worst_val = worst["Category"], worst["Registrations"]
120
+
121
+ # Avg YoY growth (if column exists)
122
+ avg_yoy = filtered_df["YoY_Growth"].mean(skipna=True)
123
+
124
+ # Show metrics in 4 columns
125
+ col1, col2, col3, col4 = st.columns(4)
126
+ col1.metric("Total Registrations", f"{total_reg:,}")
127
+ col2.metric("Top Performer", best_cat, f"{best_val:,}")
128
+ col3.metric("Lowest Performer", worst_cat, f"{worst_val:,}")
129
+ col4.metric("Avg YoY Growth", f"{avg_yoy:.2f}%")
130
+
131
+
132
+ else:
133
+ st.info("👆 Choose at least one Vehicle Type or Manufacturer to see results.")
cleaned_vahan.csv ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Category,Year,Month,Month_Num,Date,Registrations
2
+ 2-WHEELER,2021,APR,4,2021-04-01,959824
3
+ 2-WHEELER,2021,AUG,8,2021-08-01,1104022
4
+ 2-WHEELER,2021,DEC,12,2021-12-01,1303517
5
+ 2-WHEELER,2021,FEB,2,2021-02-01,1242083
6
+ 2-WHEELER,2021,JAN,1,2021-01-01,1363766
7
+ 2-WHEELER,2021,JUL,7,2021-07-01,1291824
8
+ 2-WHEELER,2021,JUN,6,2021-06-01,1076107
9
+ 2-WHEELER,2021,MAR,3,2021-03-01,1353160
10
+ 2-WHEELER,2021,MAY,5,2021-05-01,459214
11
+ 2-WHEELER,2021,NOV,11,2021-11-01,1600653
12
+ 2-WHEELER,2021,OCT,10,2021-10-01,1137798
13
+ 2-WHEELER,2021,SEP,9,2021-09-01,1032856
14
+ 2-WHEELER,2022,APR,4,2022-04-01,1331199
15
+ 2-WHEELER,2022,AUG,8,2022-08-01,1181462
16
+ 2-WHEELER,2022,DEC,12,2022-12-01,1137325
17
+ 2-WHEELER,2022,FEB,2,2022-02-01,1108495
18
+ 2-WHEELER,2022,JAN,1,2022-01-01,1154846
19
+ 2-WHEELER,2022,JUL,7,2022-07-01,1137140
20
+ 2-WHEELER,2022,JUN,6,2022-06-01,1229044
21
+ 2-WHEELER,2022,MAR,3,2022-03-01,1289142
22
+ 2-WHEELER,2022,MAY,5,2022-05-01,1368602
23
+ 2-WHEELER,2022,NOV,11,2022-11-01,1856719
24
+ 2-WHEELER,2022,OCT,10,2022-10-01,1725530
25
+ 2-WHEELER,2022,SEP,9,2022-09-01,1079001
26
+ 2-WHEELER,2023,APR,4,2023-04-01,1233788
27
+ 2-WHEELER,2023,AUG,8,2023-08-01,1259224
28
+ 2-WHEELER,2023,DEC,12,2023-12-01,1454346
29
+ 2-WHEELER,2023,FEB,2,2023-02-01,1271098
30
+ 2-WHEELER,2023,JAN,1,2023-01-01,1269039
31
+ 2-WHEELER,2023,JUL,7,2023-07-01,1231973
32
+ 2-WHEELER,2023,JUN,6,2023-06-01,1314671
33
+ 2-WHEELER,2023,MAR,3,2023-03-01,1450929
34
+ 2-WHEELER,2023,MAY,5,2023-05-01,1497832
35
+ 2-WHEELER,2023,NOV,11,2023-11-01,2258989
36
+ 2-WHEELER,2023,OCT,10,2023-10-01,1514667
37
+ 2-WHEELER,2023,SEP,9,2023-09-01,1316317
38
+ 2-WHEELER,2024,APR,4,2024-04-01,1650943
39
+ 2-WHEELER,2024,AUG,8,2024-08-01,1345377
40
+ 2-WHEELER,2024,DEC,12,2024-12-01,1203980
41
+ 2-WHEELER,2024,FEB,2,2024-02-01,1447167
42
+ 2-WHEELER,2024,JAN,1,2024-01-01,1465872
43
+ 2-WHEELER,2024,JUL,7,2024-07-01,1451099
44
+ 2-WHEELER,2024,JUN,6,2024-06-01,1381848
45
+ 2-WHEELER,2024,MAR,3,2024-03-01,1538524
46
+ 2-WHEELER,2024,MAY,5,2024-05-01,1540924
47
+ 2-WHEELER,2024,NOV,11,2024-11-01,2628441
48
+ 2-WHEELER,2024,OCT,10,2024-10-01,2076261
49
+ 2-WHEELER,2024,SEP,9,2024-09-01,1209582
50
+ 2-WHEELER,2025,APR,4,2025-04-01,1697116
51
+ 2-WHEELER,2025,AUG,8,2025-08-01,803654
52
+ 2-WHEELER,2025,FEB,2,2025-02-01,1362697
53
+ 2-WHEELER,2025,JAN,1,2025-01-01,1535146
54
+ 2-WHEELER,2025,JUL,7,2025-07-01,1360098
55
+ 2-WHEELER,2025,JUN,6,2025-06-01,1453385
56
+ 2-WHEELER,2025,MAR,3,2025-03-01,1522261
57
+ 2-WHEELER,2025,MAY,5,2025-05-01,1661394
58
+ 3-WHEELER,2021,APR,4,2021-04-01,24500
59
+ 3-WHEELER,2021,AUG,8,2021-08-01,33985
60
+ 3-WHEELER,2021,DEC,12,2021-12-01,48296
61
+ 3-WHEELER,2021,FEB,2,2021-02-01,37573
62
+ 3-WHEELER,2021,JAN,1,2021-01-01,35816
63
+ 3-WHEELER,2021,JUL,7,2021-07-01,32133
64
+ 3-WHEELER,2021,JUN,6,2021-06-01,16743
65
+ 3-WHEELER,2021,MAR,3,2021-03-01,43053
66
+ 3-WHEELER,2021,MAY,5,2021-05-01,5883
67
+ 3-WHEELER,2021,NOV,11,2021-11-01,44760
68
+ 3-WHEELER,2021,OCT,10,2021-10-01,44407
69
+ 3-WHEELER,2021,SEP,9,2021-09-01,40723
70
+ 3-WHEELER,2022,APR,4,2022-04-01,45546
71
+ 3-WHEELER,2022,AUG,8,2022-08-01,60619
72
+ 3-WHEELER,2022,DEC,12,2022-12-01,69576
73
+ 3-WHEELER,2022,FEB,2,2022-02-01,42107
74
+ 3-WHEELER,2022,JAN,1,2022-01-01,43649
75
+ 3-WHEELER,2022,JUL,7,2022-07-01,54191
76
+ 3-WHEELER,2022,JUN,6,2022-06-01,49539
77
+ 3-WHEELER,2022,MAR,3,2022-03-01,51802
78
+ 3-WHEELER,2022,MAY,5,2022-05-01,44688
79
+ 3-WHEELER,2022,NOV,11,2022-11-01,80971
80
+ 3-WHEELER,2022,OCT,10,2022-10-01,72307
81
+ 3-WHEELER,2022,SEP,9,2022-09-01,68996
82
+ 3-WHEELER,2023,APR,4,2023-04-01,75768
83
+ 3-WHEELER,2023,AUG,8,2023-08-01,106140
84
+ 3-WHEELER,2023,DEC,12,2023-12-01,99776
85
+ 3-WHEELER,2023,FEB,2,2023-02-01,78490
86
+ 3-WHEELER,2023,JAN,1,2023-01-01,72146
87
+ 3-WHEELER,2023,JUL,7,2023-07-01,100070
88
+ 3-WHEELER,2023,JUN,6,2023-06-01,91565
89
+ 3-WHEELER,2023,MAR,3,2023-03-01,94657
90
+ 3-WHEELER,2023,MAY,5,2023-05-01,84390
91
+ 3-WHEELER,2023,NOV,11,2023-11-01,104575
92
+ 3-WHEELER,2023,OCT,10,2023-10-01,113731
93
+ 3-WHEELER,2023,SEP,9,2023-09-01,108606
94
+ 3-WHEELER,2024,APR,4,2024-04-01,80129
95
+ 3-WHEELER,2024,AUG,8,2024-08-01,105494
96
+ 3-WHEELER,2024,DEC,12,2024-12-01,93889
97
+ 3-WHEELER,2024,FEB,2,2024-02-01,96018
98
+ 3-WHEELER,2024,JAN,1,2024-01-01,100160
99
+ 3-WHEELER,2024,JUL,7,2024-07-01,110509
100
+ 3-WHEELER,2024,JUN,6,2024-06-01,94327
101
+ 3-WHEELER,2024,MAR,3,2024-03-01,105351
102
+ 3-WHEELER,2024,MAY,5,2024-05-01,98273
103
+ 3-WHEELER,2024,NOV,11,2024-11-01,108328
104
+ 3-WHEELER,2024,OCT,10,2024-10-01,122852
105
+ 3-WHEELER,2024,SEP,9,2024-09-01,106533
106
+ 3-WHEELER,2025,APR,4,2025-04-01,99774
107
+ 3-WHEELER,2025,AUG,8,2025-08-01,56366
108
+ 3-WHEELER,2025,FEB,2,2025-02-01,94192
109
+ 3-WHEELER,2025,JAN,1,2025-01-01,107026
110
+ 3-WHEELER,2025,JUL,7,2025-07-01,111421
111
+ 3-WHEELER,2025,JUN,6,2025-06-01,100635
112
+ 3-WHEELER,2025,MAR,3,2025-03-01,99381
113
+ 3-WHEELER,2025,MAY,5,2025-05-01,104463
114
+ 4-WHEELER,2021,APR,4,2021-04-01,328920
115
+ 4-WHEELER,2021,AUG,8,2021-08-01,425385
116
+ 4-WHEELER,2021,DEC,12,2021-12-01,412448
117
+ 4-WHEELER,2021,FEB,2,2021-02-01,425323
118
+ 4-WHEELER,2021,JAN,1,2021-01-01,465018
119
+ 4-WHEELER,2021,JUL,7,2021-07-01,448808
120
+ 4-WHEELER,2021,JUN,6,2021-06-01,313443
121
+ 4-WHEELER,2021,MAR,3,2021-03-01,479873
122
+ 4-WHEELER,2021,MAY,5,2021-05-01,133065
123
+ 4-WHEELER,2021,NOV,11,2021-11-01,387740
124
+ 4-WHEELER,2021,OCT,10,2021-10-01,369862
125
+ 4-WHEELER,2021,SEP,9,2021-09-01,388661
126
+ 4-WHEELER,2022,APR,4,2022-04-01,430247
127
+ 4-WHEELER,2022,AUG,8,2022-08-01,438711
128
+ 4-WHEELER,2022,DEC,12,2022-12-01,444935
129
+ 4-WHEELER,2022,FEB,2,2022-02-01,396317
130
+ 4-WHEELER,2022,JAN,1,2022-01-01,427637
131
+ 4-WHEELER,2022,JUL,7,2022-07-01,425641
132
+ 4-WHEELER,2022,JUN,6,2022-06-01,431657
133
+ 4-WHEELER,2022,MAR,3,2022-03-01,463345
134
+ 4-WHEELER,2022,MAY,5,2022-05-01,428816
135
+ 4-WHEELER,2022,NOV,11,2022-11-01,480517
136
+ 4-WHEELER,2022,OCT,10,2022-10-01,504571
137
+ 4-WHEELER,2022,SEP,9,2022-09-01,423350
138
+ 4-WHEELER,2023,APR,4,2023-04-01,437833
139
+ 4-WHEELER,2023,AUG,8,2023-08-01,479790
140
+ 4-WHEELER,2023,DEC,12,2023-12-01,460490
141
+ 4-WHEELER,2023,FEB,2,2023-02-01,452560
142
+ 4-WHEELER,2023,JAN,1,2023-01-01,515575
143
+ 4-WHEELER,2023,JUL,7,2023-07-01,460937
144
+ 4-WHEELER,2023,JUN,6,2023-06-01,482424
145
+ 4-WHEELER,2023,MAR,3,2023-03-01,524253
146
+ 4-WHEELER,2023,MAY,5,2023-05-01,460709
147
+ 4-WHEELER,2023,NOV,11,2023-11-01,528140
148
+ 4-WHEELER,2023,OCT,10,2023-10-01,522799
149
+ 4-WHEELER,2023,SEP,9,2023-09-01,480260
150
+ 4-WHEELER,2024,APR,4,2024-04-01,497382
151
+ 4-WHEELER,2024,AUG,8,2024-08-01,463794
152
+ 4-WHEELER,2024,DEC,12,2024-12-01,477803
153
+ 4-WHEELER,2024,FEB,2,2024-02-01,510710
154
+ 4-WHEELER,2024,JAN,1,2024-01-01,590397
155
+ 4-WHEELER,2024,JUL,7,2024-07-01,495478
156
+ 4-WHEELER,2024,JUN,6,2024-06-01,439617
157
+ 4-WHEELER,2024,MAR,3,2024-03-01,504653
158
+ 4-WHEELER,2024,MAY,5,2024-05-01,470726
159
+ 4-WHEELER,2024,NOV,11,2024-11-01,501045
160
+ 4-WHEELER,2024,OCT,10,2024-10-01,670922
161
+ 4-WHEELER,2024,SEP,9,2024-09-01,424964
162
+ 4-WHEELER,2025,APR,4,2025-04-01,520189
163
+ 4-WHEELER,2025,AUG,8,2025-08-01,275156
164
+ 4-WHEELER,2025,FEB,2,2025-02-01,466158
165
+ 4-WHEELER,2025,JAN,1,2025-01-01,679403
166
+ 4-WHEELER,2025,JUL,7,2025-07-01,505695
167
+ 4-WHEELER,2025,JUN,6,2025-06-01,469468
168
+ 4-WHEELER,2025,MAR,3,2025-03-01,533497
169
+ 4-WHEELER,2025,MAY,5,2025-05-01,469462
cleaned_vahan_final.csv ADDED
The diff for this file is too large to render. See raw diff