-
Notifications
You must be signed in to change notification settings - Fork 0
/
phonepe_pulse.py
638 lines (560 loc) · 31.1 KB
/
phonepe_pulse.py
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
import streamlit as st
from PIL import Image
import os
import json
from streamlit_option_menu import option_menu
import subprocess
import plotly.express as px
import pandas as pd
import sqlite3
import requests
phn = Image.open("images/phn.png")
st.set_page_config(page_title="PhonePe Pulse", page_icon=phn, layout="wide", )
#CLONING TH PHONEPE--PULSE GITHUB REPOSITORY
response = requests.get('https://api.github.com/repos/PhonePe/pulse')
repo = response.json()
clone_url = repo['clone_url']
#DIRECTING THE REPOSITORY TO THE LOCAL DIRECTORY
repo_name = "pulse"
clone_dir = os.path.join(os.getcwd(), repo_name)
subprocess.run(["git", "clone", clone_url, clone_dir], check=True)
# TO GET THE DATA-FRAME OF AGGREGATED <--> TRANSACTION
path1 = "/home/vazanth/PycharmProjects/phonepe/pulse/data/aggregated/transaction/country/india/state/"
Agg_state_list = os.listdir(path1)
col1 = {'State': [], 'Year': [], 'Quater': [], 'Transaction_type': [], 'Transaction_count': [],
'Transaction_amount': []}
for i in Agg_state_list:
p_i = path1 + i + "/"
Agg_yr = os.listdir(p_i)
for j in Agg_yr:
p_j = p_i + j + "/"
Agg_yr_list = os.listdir(p_j)
for k in Agg_yr_list:
p_k = p_j + k
# print(p_k)
Data = open(p_k, 'r')
A = json.load(Data)
for z in A['data']['transactionData']:
Name = z['name']
count = z['paymentInstruments'][0]['count']
amount = z['paymentInstruments'][0]['amount']
col1['Transaction_type'].append(Name)
col1['Transaction_count'].append(count)
col1['Transaction_amount'].append(amount)
col1['State'].append(i)
col1['Year'].append(j)
col1['Quater'].append(int(k.strip('.json')))
df_aggregated_transaction = pd.DataFrame(col1)
# df_aggregated_transaction
# TO GET THE DATA-FRAME OF AGGREGATED <--> USER
path2 = "/home/vazanth/PycharmProjects/phonepe/pulse/data/aggregated/user/country/india/state/"
user_list = os.listdir(path2)
col2 = {'State': [], 'Year': [], 'Quater': [], 'brands': [], 'Count': [],
'Percentage': []}
for i in user_list:
p_i = path2 + i + "/"
Agg_yr = os.listdir(p_i)
for j in Agg_yr:
p_j = p_i + j + "/"
Agg_yr_list = os.listdir(p_j)
for k in Agg_yr_list:
p_k = p_j + k
# print(p_k)
Data = open(p_k, 'r')
B = json.load(Data)
try:
for w in B["data"]["usersByDevice"]:
brand_name = w["brand"]
count_ = w["count"]
ALL_percentage = w["percentage"]
col2["brands"].append(brand_name)
col2["Count"].append(count_)
col2["Percentage"].append(ALL_percentage)
col2["State"].append(i)
col2["Year"].append(j)
col2["Quater"].append(int(k.strip('.json')))
except:
pass
df_aggregated_user = pd.DataFrame(col2)
# df_aggregated_user
# TO GET THE DATA-FRAME OF MAP <--> TRANSACTION
path3 = "/home/vazanth/PycharmProjects/phonepe/pulse/data/map/transaction/hover/country/india/state/"
hover_list = os.listdir(path3)
col3 = {'State': [], 'Year': [], 'Quater': [], 'District': [], 'count': [],
'amount': []}
for i in hover_list:
p_i = path3 + i + "/"
Agg_yr = os.listdir(p_i)
for j in Agg_yr:
p_j = p_i + j + "/"
Agg_yr_list = os.listdir(p_j)
for k in Agg_yr_list:
p_k = p_j + k
# print(p_k)
Data = open(p_k, 'r')
C = json.load(Data)
for x in C["data"]["hoverDataList"]:
District = x["name"]
count = x["metric"][0]["count"]
amount = x["metric"][0]["amount"]
col3["District"].append(District)
col3["count"].append(count)
col3["amount"].append(amount)
col3['State'].append(i)
col3['Year'].append(j)
col3['Quater'].append(int(k.strip('.json')))
df_map_transaction = pd.DataFrame(col3)
# df_map_transaction
# TO GET THE DATA-FRAME OF MAP <--> USER
path4 = "/home/vazanth/PycharmProjects/phonepe/pulse/data/map/user/hover/country/india/state/"
map_list = os.listdir(path4)
col4 = {"State": [], "Year": [], "Quater": [], "District": [],
"RegisteredUser": []}
for i in map_list:
p_i = path4 + i + "/"
Agg_yr = os.listdir(p_i)
for j in Agg_yr:
p_j = p_i + j + "/"
Agg_yr_list = os.listdir(p_j)
for k in Agg_yr_list:
p_k = p_j + k
# print(p_k)
Data = open(p_k, 'r')
D = json.load(Data)
for u in D["data"]["hoverData"].items():
district = u[0]
registereduser = u[1]["registeredUsers"]
col4["District"].append(district)
col4["RegisteredUser"].append(registereduser)
col4['State'].append(i)
col4['Year'].append(j)
col4['Quater'].append(int(k.strip('.json')))
df_map_user = pd.DataFrame(col4)
# df_map_user
# TO GET THE DATA-FRAME OF TOP <--> TRANSACTION
path5 = "/home/vazanth/PycharmProjects/phonepe/pulse/data/top/transaction/country/india/state/"
TOP_list = os.listdir(path5)
col5 = {'State': [], 'Year': [], 'Quater': [], 'District': [], 'Transaction_count': [],
'Transaction_amount': []}
for i in TOP_list:
p_i = path5 + i + "/"
Agg_yr = os.listdir(p_i)
for j in Agg_yr:
p_j = p_i + j + "/"
Agg_yr_list = os.listdir(p_j)
for k in Agg_yr_list:
p_k = p_j + k
# print(p_k)
Data = open(p_k, 'r')
E = json.load(Data)
for z in E['data']['pincodes']:
Name = z['entityName']
count = z['metric']['count']
amount = z['metric']['amount']
col5['District'].append(Name)
col5['Transaction_count'].append(count)
col5['Transaction_amount'].append(amount)
col5['State'].append(i)
col5['Year'].append(j)
col5['Quater'].append(int(k.strip('.json')))
df_top_transaction = pd.DataFrame(col5)
# df_top_transaction
# TO GET THE DATA-FRAME OF TOP <--> USER
path6 = "/home/vazanth/PycharmProjects/phonepe/pulse/data/top/user/country/india/state/"
USER_list = os.listdir(path6)
col6 = {'State': [], 'Year': [], 'Quater': [], 'District': [],
'RegisteredUser': []}
for i in USER_list:
p_i = path6 + i + "/"
Agg_yr = os.listdir(p_i)
for j in Agg_yr:
p_j = p_i + j + "/"
Agg_yr_list = os.listdir(p_j)
for k in Agg_yr_list:
p_k = p_j + k
# print(p_k)
Data = open(p_k, 'r')
F = json.load(Data)
for t in F['data']['pincodes']:
Name = t['name']
registeredUser = t['registeredUsers']
col6['District'].append(Name)
col6['RegisteredUser'].append(registeredUser)
col6['State'].append(i)
col6['Year'].append(j)
col6['Quater'].append(int(k.strip('.json')))
df_top_user = pd.DataFrame(col6)
# df_top_user
#CREATING CONNECTION WITH SQL SERVER
connection = sqlite3.connect("phonepe pulse.db")
cursor = connection.cursor()
df_aggregated_transaction.to_sql('aggregated_transaction', connection, if_exists='replace')
df_aggregated_user.to_sql('aggregated_user', connection, if_exists='replace')
df_map_transaction.to_sql('map_transaction', connection, if_exists='replace')
df_map_user.to_sql('map_user', connection, if_exists='replace')
df_top_transaction.to_sql('top_transaction', connection, if_exists='replace')
df_top_user.to_sql('top_user', connection, if_exists='replace')
#with st.sidebar:
SELECT = option_menu(
menu_title = None,
options = ["About","Search","Home","Basic insights","Contact"],
icons =["bar-chart","search","house","toggles","at"],
default_index=2,
orientation="horizontal",
styles={
"container": {"padding": "0!important", "background-color": "white","size":"cover"},
"icon": {"color": "black", "font-size": "20px"},
"nav-link": {"font-size": "20px", "text-align": "center", "margin": "-2px", "--hover-color": "#6F36AD"},
"nav-link-selected": {"background-color": "#6F36AD"},}
)
if SELECT == "Basic insights":
st.title("BASIC INSIGHTS")
st.write("----")
st.subheader("Let's know some basic insights about the data")
options = ["--select--","Top 10 states based on year and amount of transaction","Least 10 states based on type and amount of transaction",
"Top 10 mobile brands based on percentage of transaction","Top 10 Registered-users based on States and District(pincode)",
"Top 10 Districts based on states and amount of transaction","Least 10 Districts based on states and amount of transaction",
"Least 10 registered-users based on Districts and states","Top 10 transactions_type based on states and transaction_amount"]
select = st.selectbox("Select the option",options)
if select=="Top 10 states based on year and amount of transaction":
cursor.execute("SELECT DISTINCT State,Transaction_amount,Year,Quater FROM top_transaction GROUP BY State ORDER BY transaction_amount DESC LIMIT 10");
df = pd.DataFrame(cursor.fetchall(),columns=['State','Transaction_amount','Year','Quater'])
col1,col2 = st.columns(2)
with col1:
st.write(df)
with col2:
st.title("Top 10 states based on type and amount of transaction")
st.bar_chart(data=df,x="State",y="Transaction_amount")
elif select=="Least 10 states based on type and amount of transaction":
cursor.execute("SELECT DISTINCT State,Transaction_amount,Year,Quater FROM top_transaction GROUP BY State ORDER BY transaction_amount ASC LIMIT 10");
df = pd.DataFrame(cursor.fetchall(),columns=['State','Transaction_amount','Year','Quater'])
col1,col2 = st.columns(2)
with col1:
st.write(df)
with col2:
st.title("Least 10 states based on type and amount of transaction")
st.bar_chart(data=df,x="State",y="Transaction_amount")
elif select=="Top 10 mobile brands based on percentage of transaction":
cursor.execute("SELECT DISTINCT brands,Percentage FROM aggregated_user GROUP BY brands ORDER BY Percentage DESC LIMIT 10");
df = pd.DataFrame(cursor.fetchall(),columns=['brands','Percentage'])
col1,col2 = st.columns(2)
with col1:
st.write(df)
with col2:
st.title("Top 10 mobile brands based on percentage of transaction")
st.bar_chart(data=df,x="brands",y="Percentage")
elif select=="Top 10 Registered-users based on States and District(pincode)":
cursor.execute("SELECT DISTINCT State,District,RegisteredUser FROM top_user GROUP BY State,District ORDER BY RegisteredUser DESC LIMIT 10");
df = pd.DataFrame(cursor.fetchall(),columns=['State','District','RegisteredUser'])
col1,col2 = st.columns(2)
with col1:
st.write(df)
with col2:
st.title("Top 10 Registered-users based on States and District(pincode)")
st.bar_chart(data=df,x="State",y="RegisteredUser")
elif select=="Top 10 Districts based on states and amount of transaction":
cursor.execute("SELECT DISTINCT State,District,Transaction_amount FROM map_transaction GROUP BY State,District ORDER BY Transaction_amount DESC LIMIT 10");
df = pd.DataFrame(cursor.fetchall(),columns=['State','District','Transaction_amount'])
col1,col2 = st.columns(2)
with col1:
st.write(df)
with col2:
st.title("Top 10 Districts based on states and amount of transaction")
st.bar_chart(data=df,x="State",y="Transaction_amount")
elif select=="Least 10 Districts based on states and amount of transaction":
cursor.execute("SELECT DISTINCT State,District,Transaction_amount FROM map_transaction GROUP BY State,District ORDER BY Transaction_amount ASC LIMIT 10");
df = pd.DataFrame(cursor.fetchall(),columns=['State','District','Transaction_amount'])
col1,col2 = st.columns(2)
with col1:
st.write(df)
with col2:
st.title("Least 10 Districts based on states and amount of transaction")
st.bar_chart(data=df,x="State",y="Transaction_amount")
elif select=="Least 10 registered-users based on Districts and states":
cursor.execute("SELECT DISTINCT State,District,RegisteredUser FROM top_user GROUP BY State,District ORDER BY RegisteredUser ASC LIMIT 10");
df = pd.DataFrame(cursor.fetchall(),columns=['State','District','RegisteredUser'])
col1,col2 = st.columns(2)
with col1:
st.write(df)
with col2:
st.title("Least 10 registered-users based on Districts and states")
st.bar_chart(data=df,x="State",y="RegisteredUser")
elif select=="Top 10 transactions_type based on states and transaction_amount":
cursor.execute("SELECT DISTINCT State,Transaction_type,Transaction_amount FROM aggregated_transaction GROUP BY State,Transaction_type ORDER BY Transaction_amount DESC LIMIT 10");
df = pd.DataFrame(cursor.fetchall(),columns=['State','Transaction_type','Transaction_amount'])
col1,col2 = st.columns(2)
with col1:
st.write(df)
with col2:
st.title("Top 10 transactions_type based on states and transaction_amount")
st.bar_chart(data=df,x="State",y="Transaction_amount")
if SELECT == "Home":
col1,col2, = st.columns(2)
col1.image(Image.open("images/phonepe.png"),width = 500)
with col1:
st.subheader("PhonePe is an Indian digital payments and financial technology company headquartered in Bengaluru, Karnataka, India. PhonePe was founded in December 2015, by Sameer Nigam, Rahul Chari and Burzin Engineer. The PhonePe app, based on the Unified Payments Interface (UPI), went live in August 2016. It is owned by Flipkart, a subsidiary of Walmart.")
st.download_button("DOWNLOAD THE APP NOW", "https://www.phonepe.com/app-download/")
with col2:
st.video("images/upi.mp4")
if SELECT == "About":
col1,col2 = st.columns(2)
with col1:
st.video("images/pulse-video.mp4")
with col2:
st.image(Image.open("images/PhonePe_Logo.jpg"),width = 600)
st.write("---")
st.subheader("The Indian digital payments story has truly captured the world's imagination."
" From the largest towns to the remotest villages, there is a payments revolution being driven by the penetration of mobile phones, mobile internet and state-of-the-art payments infrastructure built as Public Goods championed by the central bank and the government."
" Founded in December 2015, PhonePe has been a strong beneficiary of the API driven digitisation of payments in India. When we started, we were constantly looking for granular and definitive data sources on digital payments in India. "
"PhonePe Pulse is our way of giving back to the digital payments ecosystem.")
st.write("---")
col1,col2 = st.columns(2)
with col1:
st.title("THE BEAT OF PHONEPE")
st.write("---")
st.subheader("Phonepe became a leading digital payments company")
st.image(Image.open("images/top.jpeg"),width = 400)
with open("images/annual report.pdf","rb") as f:
data = f.read()
st.download_button("DOWNLOAD REPORT",data,file_name="annual report.pdf")
with col2:
st.image(Image.open("images/report.jpeg"),width = 800)
if SELECT == "Contact":
name = "DHANA VASANTH.N"
mail = (f'{"Mail :"} {"danavasanth@gmail.com"}')
description = "An Aspiring DATA-SCIENTIST..!"
social_media = {
"TWITTER": "https://twitter.com/im_vazanth",
"GITHUB": "https://github.com/dhanavasanth",
"LINKEDIN": "www.linkedin.com/in/dhana-vasanth-7462a5256",
"INSTAGRAM": "https://www.instagram.com/dana_vasanth_/",
}
col1, col2, col3 = st.columns(3)
col2.image(Image.open("images/my.png"), width=350)
with col3:
st.title(name)
st.write(description)
st.write("---")
st.subheader(mail)
st.write("#")
cols = st.columns(len(social_media))
for index, (platform, link) in enumerate(social_media.items()):
cols[index].write(f"[{platform}]({link})")
if SELECT =="Search":
Topic = ["","Transaction-Type","District","Brand","Top-Transactions","Registered-users"]
choice_topic = st.selectbox("Search by",Topic)
#creating functions for query search in sqlite to get the data
def type_(type):
cursor.execute(f"SELECT DISTINCT State,Quater,Year,Transaction_type,Transaction_amount FROM aggregated_transaction WHERE Transaction_type = '{type}' ORDER BY State,Quater,Year");
df = pd.DataFrame(cursor.fetchall(), columns=['State','Quater', 'Year', 'Transaction_type', 'Transaction_amount'])
return df
def type_year(year,type):
cursor.execute(f"SELECT DISTINCT State,Year,Quater,Transaction_type,Transaction_amount FROM aggregated_transaction WHERE Year = '{year}' AND Transaction_type = '{type}' ORDER BY State,Quater,Year");
df = pd.DataFrame(cursor.fetchall(), columns=['State', 'Year',"Quater", 'Transaction_type', 'Transaction_amount'])
return df
def type_state(state,year,type):
cursor.execute(f"SELECT DISTINCT State,Year,Quater,Transaction_type,Transaction_amount FROM aggregated_transaction WHERE State = '{state}' AND Transaction_type = '{type}' And Year = '{year}' ORDER BY State,Quater,Year");
df = pd.DataFrame(cursor.fetchall(), columns=['State', 'Year',"Quater", 'Transaction_type', 'Transaction_amount'])
return df
def district_choice_state(_state):
cursor.execute(f"SELECT DISTINCT State,Year,Quater,District,amount FROM map_transaction WHERE State = '{_state}' ORDER BY State,Year,Quater,District");
df = pd.DataFrame(cursor.fetchall(), columns=['State', 'Year',"Quater", 'District', 'amount'])
return df
def dist_year_state(year,_state):
cursor.execute(f"SELECT DISTINCT State,Year,Quater,District,amount FROM map_transaction WHERE Year = '{year}' AND State = '{_state}' ORDER BY State,Year,Quater,District");
df = pd.DataFrame(cursor.fetchall(), columns=['State', 'Year',"Quater", 'District', 'amount'])
return df
def district_year_state(_dist,year,_state):
cursor.execute(f"SELECT DISTINCT State,Year,Quater,District,amount FROM map_transaction WHERE District = '{_dist}' AND State = '{_state}' AND Year = '{year}' ORDER BY State,Year,Quater,District");
df = pd.DataFrame(cursor.fetchall(), columns=['State', 'Year',"Quater", 'District', 'amount'])
return df
def brand_(brand_type):
cursor.execute(f"SELECT State,Year,Quater,brands,Percentage FROM aggregated_user WHERE brands='{brand_type}' ORDER BY State,Year,Quater,brands,Percentage DESC");
df = pd.DataFrame(cursor.fetchall(), columns=['State', 'Year',"Quater", 'brands', 'Percentage'])
return df
def brand_year(brand_type,year):
cursor.execute(f"SELECT State,Year,Quater,brands,Percentage FROM aggregated_user WHERE Year = '{year}' AND brands='{brand_type}' ORDER BY State,Year,Quater,brands,Percentage DESC");
df = pd.DataFrame(cursor.fetchall(), columns=['State', 'Year',"Quater", 'brands', 'Percentage'])
return df
def brand_state(state,brand_type,year):
cursor.execute(f"SELECT State,Year,Quater,brands,Percentage FROM aggregated_user WHERE State = '{state}' AND brands='{brand_type}' AND Year = '{year}' ORDER BY State,Year,Quater,brands,Percentage DESC");
df = pd.DataFrame(cursor.fetchall(), columns=['State', 'Year',"Quater", 'brands', 'Percentage'])
return df
def transaction_state(_state):
cursor.execute(f"SELECT State,Year,Quater,District,Transaction_count,Transaction_amount FROM top_transaction WHERE State = '{_state}' GROUP BY State,Year,Quater")
df = pd.DataFrame(cursor.fetchall(), columns=['State', 'Year',"Quater", 'District', 'Transaction_count', 'Transaction_amount'])
return df
def transaction_year(_state,_year):
cursor.execute(f"SELECT State,Year,Quater,District,Transaction_count,Transaction_amount FROM top_transaction WHERE Year = '{_year}' AND State = '{_state}' GROUP BY State,Year,Quater")
df = pd.DataFrame(cursor.fetchall(), columns=['State', 'Year',"Quater", 'District', 'Transaction_count', 'Transaction_amount'])
return df
def transaction_quater(_state,_year,_quater):
cursor.execute(f"SELECT State,Year,Quater,District,Transaction_count,Transaction_amount FROM top_transaction WHERE Year = '{_year}' AND Quater = '{_quater}' AND State = '{_state}' GROUP BY State,Year,Quater")
df = pd.DataFrame(cursor.fetchall(), columns=['State', 'Year',"Quater", 'District', 'Transaction_count', 'Transaction_amount'])
return df
def registered_user_state(_state):
cursor.execute(f"SELECT State,Year,Quater,District,RegisteredUser FROM map_user WHERE State = '{_state}' ORDER BY State,Year,Quater,District")
df = pd.DataFrame(cursor.fetchall(), columns=['State', 'Year',"Quater", 'District', 'RegisteredUser'])
return df
def registered_user_year(_state,_year):
cursor.execute(f"SELECT State,Year,Quater,District,RegisteredUser FROM map_user WHERE Year = '{_year}' AND State = '{_state}' ORDER BY State,Year,Quater,District")
df = pd.DataFrame(cursor.fetchall(), columns=['State', 'Year',"Quater", 'District', 'RegisteredUser'])
return df
def registered_user_district(_state,_year,_dist):
cursor.execute(f"SELECT State,Year,Quater,District,RegisteredUser FROM map_user WHERE Year = '{_year}' AND State = '{_state}' AND District = '{_dist}' ORDER BY State,Year,Quater,District")
df = pd.DataFrame(cursor.fetchall(), columns=['State', 'Year',"Quater", 'District', 'RegisteredUser'])
return df
if choice_topic=="Transaction-Type":
col1,col2,col3 = st.columns(3)
with col1:
st.subheader("-- 5 TYPES OF TRANSACTION --")
transaction_type = st.selectbox("search by", ["Choose an option", "Peer-to-peer payments",
"Merchant payments", "Financial Services",
"Recharge & bill payments", "Others"], 0)
with col2:
st.subheader("-- 5 YEARS --")
choice_year = st.selectbox("Year", ["", "2018", "2019", "2020", "2021", "2022"], 0)
with col3:
st.subheader("-- 36 STATES --")
menu_state = ["", 'uttar-pradesh', 'jharkhand', 'puducherry', 'rajasthan', 'odisha', 'nagaland',
'chandigarh', 'dadra-&-nagar-haveli-&-daman-&-diu', 'assam', 'haryana', 'jammu-&-kashmir',
'tamil-nadu', 'himachal-pradesh', 'ladakh', 'bihar', 'maharashtra', 'uttarakhand',
'karnataka', 'lakshadweep', 'andhra-pradesh', 'sikkim', 'madhya-pradesh', 'mizoram',
'kerala', 'manipur', 'arunachal-pradesh', 'andaman-&-nicobar-islands', 'delhi', 'tripura',
'chhattisgarh', 'meghalaya', 'goa', 'west-bengal', 'telangana', 'gujarat', 'punjab']
choice_state = st.selectbox("State", menu_state, 0)
if transaction_type:
col1,col2,col3, = st.columns(3)
with col1:
st.subheader(f'{transaction_type}')
st.write(type_(transaction_type))
if transaction_type and choice_year:
with col2:
st.subheader(f' in {choice_year}')
st.write(type_year(choice_year,transaction_type))
if transaction_type and choice_state and choice_year:
with col3:
st.subheader(f' in {choice_state}')
st.write(type_state(choice_state,choice_year,transaction_type))
if choice_topic=="District":
col1,col2,col3 = st.columns(3)
with col1:
st.subheader("-- 36 STATES --")
menu_state = ["", 'uttar-pradesh', 'jharkhand', 'puducherry', 'rajasthan', 'odisha', 'nagaland',
'chandigarh', 'dadra-&-nagar-haveli-&-daman-&-diu', 'assam', 'haryana', 'jammu-&-kashmir',
'tamil-nadu', 'himachal-pradesh', 'ladakh', 'bihar', 'maharashtra', 'uttarakhand',
'karnataka', 'lakshadweep', 'andhra-pradesh', 'sikkim', 'madhya-pradesh', 'mizoram',
'kerala', 'manipur', 'arunachal-pradesh', 'andaman-&-nicobar-islands', 'delhi', 'tripura',
'chhattisgarh', 'meghalaya', 'goa', 'west-bengal', 'telangana', 'gujarat', 'punjab']
choice_state = st.selectbox("State", menu_state, 0)
with col2:
st.subheader("-- 5 YEARS --")
choice_year = st.selectbox("Year", ["", "2018", "2019", "2020", "2021", "2022"], 0)
with col3:
st.subheader("-- SELECT DISTRICTS --")
district = st.selectbox("search by", df_map_transaction["District"].unique().tolist())
if choice_state:
col1,col2,col3 = st.columns(3)
with col1:
st.subheader(f'{choice_state}')
st.write(district_choice_state(choice_state))
if choice_year and choice_state:
with col2:
st.subheader(f'in {choice_year} ')
st.write(dist_year_state(choice_year,choice_state))
if district and choice_state and choice_year:
with col3:
st.subheader(f'in {district} ')
st.write(district_year_state(district,choice_year,choice_state))
if choice_topic=="Brand":
col1,col2,col3 = st.columns(3)
with col1:
st.subheader("-- TYPES OF BRANDS --")
mobiles = ["",'Xiaomi', 'Vivo', 'Samsung', 'Oppo', 'Realme', 'Apple', 'Huawei', 'Motorola', 'Tecno', 'Infinix',
'Lenovo', 'Lava', 'OnePlus', 'Micromax', 'Asus', 'Gionee', 'HMD Global', 'COOLPAD', 'Lyf',
'Others']
brand_type = st.selectbox("search by",mobiles, 0)
with col2:
st.subheader("-- 5 YEARS --")
choice_year = st.selectbox("Year", ["", "2018", "2019", "2020", "2021", "2022"], 0)
with col3:
st.subheader("-- 36 STATES --")
menu_state = ["", 'uttar-pradesh', 'jharkhand', 'puducherry', 'rajasthan', 'odisha', 'nagaland',
'chandigarh', 'dadra-&-nagar-haveli-&-daman-&-diu', 'assam', 'haryana', 'jammu-&-kashmir',
'tamil-nadu', 'himachal-pradesh', 'ladakh', 'bihar', 'maharashtra', 'uttarakhand',
'karnataka', 'lakshadweep', 'andhra-pradesh', 'sikkim', 'madhya-pradesh', 'mizoram',
'kerala', 'manipur', 'arunachal-pradesh', 'andaman-&-nicobar-islands', 'delhi', 'tripura',
'chhattisgarh', 'meghalaya', 'goa', 'west-bengal', 'telangana', 'gujarat', 'punjab']
choice_state = st.selectbox("State", menu_state, 0)
if brand_type:
col1,col2,col3, = st.columns(3)
with col1:
st.subheader(f'{brand_type}')
st.write(brand_(brand_type))
if brand_type and choice_year:
with col2:
st.subheader(f' in {choice_year}')
st.write(brand_year(brand_type,choice_year))
if brand_type and choice_state and choice_year:
with col3:
st.subheader(f' in {choice_state}')
st.write(brand_state(choice_state,brand_type,choice_year))
if choice_topic=="Top-Transactions":
col1,col2,col3 = st.columns(3)
with col1:
st.subheader("-- 36 STATES --")
menu_state = ["", 'uttar-pradesh', 'jharkhand', 'puducherry', 'rajasthan', 'odisha', 'nagaland',
'chandigarh', 'dadra-&-nagar-haveli-&-daman-&-diu', 'assam', 'haryana', 'jammu-&-kashmir',
'tamil-nadu', 'himachal-pradesh', 'ladakh', 'bihar', 'maharashtra', 'uttarakhand',
'karnataka', 'lakshadweep', 'andhra-pradesh', 'sikkim', 'madhya-pradesh', 'mizoram',
'kerala', 'manipur', 'arunachal-pradesh', 'andaman-&-nicobar-islands', 'delhi', 'tripura',
'chhattisgarh', 'meghalaya', 'goa', 'west-bengal', 'telangana', 'gujarat', 'punjab']
choice_state = st.selectbox("State", menu_state, 0)
with col2:
st.subheader("-- 5 YEARS --")
choice_year = st.selectbox("Year", ["", "2018", "2019", "2020", "2021", "2022"], 0)
with col3:
st.subheader("--4 Quaters --")
menu_quater = ["", "1", "2", "3", "4"]
choice_quater = st.selectbox("Quater", menu_quater, 0)
if choice_state:
with col1:
st.subheader(f'{choice_state}')
st.write(transaction_state(choice_state))
if choice_state and choice_year:
with col2:
st.subheader(f'{choice_year}')
st.write(transaction_year(choice_state,choice_year))
if choice_state and choice_quater:
with col3:
st.subheader(f'{choice_quater}')
st.write(transaction_quater(choice_state,choice_year,choice_quater))
if choice_topic=="Registered-users":
col1,col2,col3 = st.columns(3)
with col1:
st.subheader("-- 36 STATES --")
menu_state = ["", 'uttar-pradesh', 'jharkhand', 'puducherry', 'rajasthan', 'odisha', 'nagaland',
'chandigarh', 'dadra-&-nagar-haveli-&-daman-&-diu', 'assam', 'haryana', 'jammu-&-kashmir',
'tamil-nadu', 'himachal-pradesh', 'ladakh', 'bihar', 'maharashtra', 'uttarakhand',
'karnataka', 'lakshadweep', 'andhra-pradesh', 'sikkim', 'madhya-pradesh', 'mizoram',
'kerala', 'manipur', 'arunachal-pradesh', 'andaman-&-nicobar-islands', 'delhi', 'tripura',
'chhattisgarh', 'meghalaya', 'goa', 'west-bengal', 'telangana', 'gujarat', 'punjab']
choice_state = st.selectbox("State", menu_state, 0)
with col2:
st.subheader("-- 5 YEARS --")
choice_year = st.selectbox("Year", ["", "2018", "2019", "2020", "2021", "2022"], 0)
with col3:
st.subheader("-- SELECT DISTRICTS --")
district = st.selectbox("search by", df_map_transaction["District"].unique().tolist())
if choice_state:
with col1:
st.subheader(f'{choice_state}')
st.write(registered_user_state(choice_state))
if choice_state and choice_year:
with col2:
st.subheader(f'{choice_year}')
st.write(registered_user_year(choice_state,choice_year))
if choice_state and choice_year and district:
with col3:
st.subheader(f'{district}')
st.write(registered_user_district(choice_state,choice_year,district))