-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mini_Project_Group16.py
976 lines (500 loc) · 24.8 KB
/
Mini_Project_Group16.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
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
#!/usr/bin/env python
# coding: utf-8
# This dataset Contains Information about Indian Startups from 2015-2019 regarding information about startups such as their location,amount of funding they have received etc.This dataset can help us understand the startup landscape and help us in comparing with current startup landscape in india.
# In[2]:
'''Importing Libraries'''
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import re
pd.set_option('display.max_rows',3000)
# In[3]:
'''Load Data and rename columns to enable us to use dot notation and to parse Date as a datetime object which can
give us much more insights with the dates.Header tells pandas to ignore the first line which is the header of the
column
Having Some Issue with the Geomapping Code.Cleaned Up the Replace Method Now
Removing the Remarks Column Since there are around 85% values empty
'''
startup_data=pd.read_csv('startup_funding_modified.csv',header=0,encoding='utf8',names=['Sr_No','Startup_Date','Startup_Name','Industry_Vertical','SubVertical','City_Location','Investor_Name','Investment_Type','Amount_in_USD','Remarks'])
startup_data.drop(columns='Remarks',inplace=True)
# In[4]:
startup_data
# In[5]:
'''Information about the memory consumption of the dataset.This step is important as it can tell us if we need to
read the dataset in chunks while reading the data in whichever format we have available'''
startup_data.info(memory_usage='deep')
# In[6]:
'''Basic stats about the dataset'''
startup_data.describe(include=['object','int'])
# In[7]:
'''Fixed Erroneous records from the dataset file so that no issues in python file.'''
startup_data["Startup_Date"]= pd.to_datetime(startup_data["Startup_Date"])
# In[8]:
startup_data.head(10)
# In[9]:
startup_data.dtypes
# In[10]:
print(startup_data['Startup_Name'].nunique())
# In[11]:
get_ipython().run_line_magic('matplotlib', 'inline')
# In[12]:
city_data=startup_data.City_Location
replacement_dictionary={"USA":np.NaN,"US":np.NaN,"US/India":np.NaN,"Dallas":np.NaN,"Boston":np.NaN,"New York":np.NaN,"London":np.NaN,"Nairobi":np.NaN,"SFO / Karnataka":np.NaN,"Seattle":np.NaN,"San Francisco":np.NaN,"Santa Monica":np.NaN,"Missourie":np.NaN,"India":np.NaN,"Palo Alto":np.NaN,"California":np.NaN,"SFO / Bangalore":np.NaN,"Burnsville":np.NaN,"Singapore":np.NaN,"Bangalore":"Karnataka","Belgaum":"Karnataka","Udupi":"Karnataka","New Delhi":"NCT of Delhi","Gurgaon":"NCT of Delhi","Noida":"NCT of Delhi","Delhi":"NCT of Delhi","Gurugram":"NCT of Delhi","Mumbai":"Maharashtra","Pune":"Maharashtra","Nagpur":"Maharashtra","Hyderabad":"Telangana","Faridabad":"Haryana","Surat":"Gujarat","Ahmedabad":"Gujarat","Ahemdabad":"Gujarat","Ahemadabad":"Gujarat","Vadodara":"Gujarat","Jaipur":"Rajasthan","Jodhpur":"Rajasthan","Udaipur":"Rajasthan","Kolkata":"West Bengal","Kolkatta":"West Bengal","Indore":"Madhya Pradesh","Bhopal":"Madhya Pradesh","Gwalior":"Madhya Pradesh","Coimbatore":"Tamil Nadu","Karur":"Tamil Nadu","Hubli":"Tamil Nadu","Panji":"Goa","Panaji":"Goa","Kozhikode":"Kerala","Trivandrum":"Kerala","Agra":"Uttar Pradesh","Kanpur":"Uttar Pradesh","Lucknow":"Uttar Pradesh","Varanasi":"Uttar Pradesh","Gaya":"Bihar","Bhubneswar":"Odisha","Bhubaneswar":"Odisha","New New Delhi":"NCT of Delhi","Nw Delhi":"NCT of Delhi","Kochi":"Kerala","Srinagar":"Jammu & Kashmir","Rourkela":"Bihar","Siliguri":"West Bengal"}
city_data=startup_data.City_Location.replace(replacement_dictionary)
startup_data['New_City_Location']=city_data
# In[13]:
city_data=startup_data.City_Location
replacement_dictionary={"USA":np.NaN,"US":np.NaN,"US/India":np.NaN,"Dallas":np.NaN,"Boston":np.NaN,"New York":np.NaN,"London":np.NaN,"Nairobi":np.NaN,"SFO / Karnataka":np.NaN,"Seattle":np.NaN,"San Francisco":np.NaN,"Santa Monica":np.NaN,"Missourie":np.NaN,"India":np.NaN,"Palo Alto":np.NaN,"California":np.NaN,"SFO / Bangalore":np.NaN,"Burnsville":np.NaN,"Singapore":np.NaN,"Bangalore":"Karnataka","Belgaum":"Karnataka","Udupi":"Karnataka","New Delhi":"NCT of Delhi","Gurgaon":"NCT of Delhi","Noida":"NCT of Delhi","Delhi":"NCT of Delhi","Gurugram":"NCT of Delhi","Mumbai":"Maharashtra","Pune":"Maharashtra","Nagpur":"Maharashtra","Hyderabad":"Telangana","Faridabad":"Haryana","Surat":"Gujarat","Ahmedabad":"Gujarat","Ahemdabad":"Gujarat","Ahemadabad":"Gujarat","Vadodara":"Gujarat","Jaipur":"Rajasthan","Jodhpur":"Rajasthan","Udaipur":"Rajasthan","Kolkata":"West Bengal","Kolkatta":"West Bengal","Indore":"Madhya Pradesh","Bhopal":"Madhya Pradesh","Gwalior":"Madhya Pradesh","Coimbatore":"Tamil Nadu","Karur":"Tamil Nadu","Hubli":"Tamil Nadu","Panji":"Goa","Panaji":"Goa","Kozhikode":"Kerala","Trivandrum":"Kerala","Agra":"Uttar Pradesh","Kanpur":"Uttar Pradesh","Lucknow":"Uttar Pradesh","Varanasi":"Uttar Pradesh","Gaya":"Bihar","Bhubneswar":"Odisha","Bhubaneswar":"Odisha","New New Delhi":"NCT of Delhi","Nw Delhi":"NCT of Delhi","Kochi":"Kerala","Srinagar":"Jammu & Kashmir","Rourkela":"Bihar","Siliguri":"West Bengal"}
city_data=startup_data.City_Location.replace(replacement_dictionary)
startup_data['New_City_Location']=city_data
# In[14]:
# startup_data.New_City_Location.value_counts(dropna=False)
startup_data.dropna(subset=['New_City_Location'],inplace=True)
startup_data.isna().sum()
# new_startup_data=startup_data.loc[:,['New_City_Location']]
# In[15]:
new_dataframe=pd.merge(left=geo_data,right=startup_data,left_on='ST_NM',right_on='New_City_Location')
# new_dataframe[new_dataframe.ST_NM.isna()]
# In[16]:
'''Percentage of Missing records'''
startup_data.isnull().sum()/len(startup_data)
# In[17]:
get_ipython().run_line_magic('pinfo', 'sns.scatterplot')
# In[18]:
'''Inference
The startup scene in india basically peaked at around 2016 and has been on a decline ever since.Maybe some governmental factors have come into picture or there are too many people trying to jump in this field.This has resulted in lesser amount of funding for everybody
'''
plt.figure(figsize=(15,10))
plt.xlabel("Year",fontsize=12)
plt.ylabel("Count of Startups year Wise",fontsize=12)
startup_data.Startup_Date.dt.year.value_counts().sort_index().plot(kind='bar')
# In[19]:
'''Startups which have received funding in the year 2019'''
startup_fund_2019=startup_data.loc[startup_data.Startup_Date.dt.year==2019]
# In[20]:
max(startup_fund_2019.Amount_in_USD)
# In[21]:
startup_data.Amount_in_USD=startup_data.Amount_in_USD.replace(r'[,]','',regex=True)
# startup_data.Amount_in_USD=startup_data.Amount_in_USD.replace('\.\d*','',regex=True)
startup_data.Amount_in_USD=startup_data.Amount_in_USD.replace(r'\+*','',regex=True)
startup_data.drop(startup_data.loc[(startup_data.Amount_in_USD=='Undisclosed') | (startup_data.Amount_in_USD=='undisclosed')].index,inplace=True)
startup_data.Amount_in_USD.fillna(0,inplace=True)
startup_data.Amount_in_USD=pd.to_numeric(startup_data.Amount_in_USD)
# In[22]:
startup_data.Amount_in_USD.value_counts(dropna=False)
# In[23]:
'''Inference
Karnataka has the Highest Number of Startups with the Most Value
Kerala has the least Startups in terms of value
Surprisingly,Value of Startups in Haryana is more than that of Maharashtra(Check Startups based on New City Localtion)
'''
plt.figure(figsize=(15,10))
sns.barplot(x='Amount_in_USD',y='New_City_Location',data=startup_data)
# In[24]:
max(startup_fund_2019.Amount_in_USD)
# In[25]:
min(startup_fund_2019.Amount_in_USD)
# In[28]:
startup_fund_2016=startup_data.loc[startup_data.Startup_Date.dt.year==2016]
print(max(startup_fund_2016.Amount_in_USD))
print(min(startup_fund_2016.Amount_in_USD))
# In[29]:
print(startup_fund_2016.Amount_in_USD.mean())
# In[31]:
startup_fund_2019
# In[32]:
startup_fund_2019.Amount_in_USD=startup_fund_2019.Amount_in_USD({"undisclosed":"0"})
# In[33]:
startup_fund_2019.replace(to_replace="Undisclosed",value="0")
# In[34]:
startup_fund_2019.replace(to_replace="undisclosed",value="0")
# In[35]:
startup_fund_2019['Amount_in_USD']=startup_fund_2019['Amount_in_USD'].str.lower()
# In[36]:
startup_data['Amount_in_USD']=startup_data['Amount_in_USD'].str.lower()
# In[37]:
replace_values = {'undisclosed' : 0, 'Undisclosed' : 0.0, '14,342,000+' : '14,342,000'}
# In[38]:
startup_fund_2019 = startup_fund_2019.replace({"Amount_in_USD": replace_values})
# In[39]:
startup_fund_2019
# In[40]:
max(startup_fund_2019.Amount_in_USD)
# In[41]:
print(max(startup_fund_2019.Amount_in_USD))
# In[42]:
int(max(startup_fund_2019.Amount_in_USD))
# In[43]:
startup_fund_2019.Amount_in_USD
# In[44]:
startup_fund_2019.Amount_in_USD.sort()
# In[45]:
startup_fund_2019.sort_values(by=['Amount_in_USD'], inplace=True, ascending=False)
# In[46]:
startup_fund_2019.dtypes
# In[47]:
startup_fund_2019=startup_fund_2019.sort_values(by='Amount_in_USD', inplace=True, ascending=False)
# In[48]:
def clean_amount(x):
#x = ''.join([c for c in str(x) if c in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']])
x = str(x).replace(",","").replace("+","")
x = str(x).lower().replace("undisclosed","")
x = str(x).lower().replace("n/a","")
if x == '':
x = '-999'
return x
startup_data["CleanedAmount"] = startup_data["Amount_in_USD"].apply(lambda x: float(clean_amount(x)))
Amount_in_USD = startup_data["CleanedAmount"]
Amount_in_USD = Amount_in_USD[~np.isnan(Amount_in_USD)]
Amount_in_USD = Amount_in_USD[Amount_in_USD!=-999]
plt.figure(figsize=(8,6))
plt.scatter(range(len(Amount_in_USD)), np.sort(Amount_in_USD.values), color="#1E90FF")
plt.xlabel('index', fontsize=12)
plt.ylabel('Funding value in USD', fontsize=12)
plt.title("Distribution of funding value in USD")
plt.show()
# In[49]:
startup_data.iloc[startup_data["CleanedAmount"].sort_values(ascending=True).index[:5]]
# In[50]:
startup_data
# In[51]:
startup_data.sort_values("CleanedAmount", axis = 0, ascending = False,
inplace = True, na_position ='last')
# In[52]:
startup_data
# Here,we can see that Rapido Bike Taxi, Flipkart,Paytm ,True North,Snapdeal,Ola,Ola Cabs and BigBasket are some of the highest funded startups.
# In[53]:
startup_data.unique()
# In[54]:
startup_data.Startup_Name.nunique()
# We have 2277 unique names and the rest I believe are some Startups that would have received funding multiple times
#
# In[56]:
name_data=startup_data.copy()
# In[57]:
len(name_data.Startup_Name.unique())
# In[58]:
plt.figure(figsize=(15,10))
plt.xlabel("Startup Name",fontsize=12)
plt.ylabel("No of times funding given to a startup by investor",fontsize=12)
name_data.Startup_Name.value_counts().head(20).plot(kind='bar')
# From the graph plotted, we can see that Ola cabs and Swiggy have received the most number of fundings i.e. 8 times.
# In[59]:
'''Top 10 Investors in the year 2019'''
list_investors_2019=list_investors.loc[list_investors.Startup_Date.dt.year==2019]
new_investors_2019=list_investors_2019.Investor_Name.apply(lambda x:x.split(','))
new_investors_separate_2019=[]
new_investors_separate_2019=[data.strip() for item in new_investors_2019 for data in item if data not in new_investors_separate_2019 or data != ' ']
new_investor_series_2019=pd.Series(data=new_investors_separate_2019,name='Name')
new_investor_series_2019=new_investor_series_2019.loc[new_investor_series_2019!='']
plt.figure(figsize=(15,10))
plt.xlabel("Investor_Name",fontsize=12)
plt.ylabel("No of times funding given to a startup by investor",fontsize=12)
new_investor_series_2019.value_counts().head(11).plot(kind='bar')
# In[60]:
'''Important Investors throughout the Years (Overall) and also investors for the year 2016 and 2019 for the comparisison'''
list_investors=startup_data.copy()
# In[61]:
list_startups_2019=startup_fund_2019.Startup_Name.unique().tolist()
# In[62]:
'''Very Few Startups have received funding twice in the same financial year(Which is pretty rare) while almost all the others have received only funding once in the entire year.'''
startup_fund_2019.Startup_Name.value_counts()
# In[63]:
list_startups_2016=startup_fund_2016.Startup_Name.unique().tolist()
# In[64]:
'''Here the difference in clear.The reason for more amount of funding received was due to more startups being launched and several of these startups received funding multiple times withing the same calender year(More than the number of startups in the year 2019)'''
startup_fund_2016.Startup_Name.value_counts()
# In[65]:
set(list_startups_2016).intersection(list_startups_2019)
# Thus,we can see that not a lot of commonn startups are funded in 2016 and 2019
# In[66]:
startup_data.Amount_in_USD.describe()
# In[67]:
startup_data.Investment_Type.unique()
# In[68]:
'''Clearing the Investment Type Column(Same as previous Columns)'''
copy_investment_type=startup_data.Investment_Type.copy()
copy_investment_type.fillna('Unknown',inplace=True)
replacement_dictionary_investment_type={"Private\\\\nEquity":"Private Equity","PrivateEquity":"Private Equity","Private Equity Round":"Private Equity","Private":"Private Funding","Seed Funding Round":"Seed Funding","Seed\\\\nFunding":"Seed Funding","Seed funding":"Seed Funding","Crowd funding":"Crowd Funding","Seed / Angel Funding":"Seed/Angel Funding","Seed / Angle Funding":"Seed/Angel Funding","Seed/ Angel Funding":"Seed/Angel Funding","Angel / Seed Funding":"Seed/Angel Funding","Series B (Extension)":"Series B","Debt":"Debt Funding","Angel Round":"Angel Funding","Seed":"Seed Funding","pre-series A":"Pre-Series A","pre-Series A":"Pre-Series A","Angel":"Angel Funding","Equity":"Equity Funding","Equity Based Funding":"Equity Funding"}
copy_investment_type=copy_investment_type.replace(replacement_dictionary_investment_type)
copy_investment_type.unique()
# In[69]:
startup_data.Investment_Type.fillna('Unknown',inplace=True)
startup_data.Investment_Type=startup_data.Investment_Type.replace(replacement_dictionary_investment_type)
# In[70]:
plt.figure(figsize=(20,10))
plt.yticks(fontsize=20)
plt.xticks(fontsize=20)
plt.xlabel("Count of Startups",fontsize=15)
plt.ylabel("Funding Type",fontsize=15)
startup_data.Investment_Type.value_counts().plot(kind='barh')
# In[71]:
'''Percentage of Fundings for Each Category'''
startup_data.Investment_Type.value_counts()/len(startup_data.Investment_Type)
# The major type of funding is received by seed funding,private equity and seed/angel funding.
# In[72]:
new_data=startup_data.groupby(startup_data.Startup_Date.dt.year)['Amount_in_USD'].agg({'Total_Sum':'sum',"Total_Avg":'mean'})
# In[73]:
fig,ax=plt.subplots(1,2,figsize=(15,10))
ax[0].ticklabel_format(style='plain', axis='y')
ax[1].ticklabel_format(style='plain', axis='y')
sns.barplot(x=new_data.index,y=new_data.Total_Sum,ax=ax[0])
sns.barplot(x=new_data.index,y=new_data.Total_Avg,ax=ax[1])
# Inference:Even Though the Year 2016 had the Most Amount of Startups out of all the years,neither the amount of money invested(Total/Mean) is among the highest.Surprisingly,the Average Highest Funding is received in the year 2019.
# In[74]:
plt.figure(figsize=(14,5))
iv=startup_data['Industry_Vertical'].value_counts().head(10)
iv.plot.bar()
plt.title('Frequency of Industry Vertical ')
plt.ylabel('Frequency')
plt.xlabel('Industry Vertical')
plt.show()
# In[75]:
##### In which sector there are most startups
d=startup_data['Industry_Vertical'].value_counts().head(5)
f=startup_data.groupby('Investment_Type').sum()['Amount_in_USD']
fig,ax=plt.subplots(nrows=1,ncols=1)
labels=[d.index,f.index]
size=[d.values,f.values]
colors = [['gold', 'yellowgreen', 'lightcoral', 'lightskyblue','pink'],['green','pink','red','yellow']]
plt.axis('equal')
explode = ((0.1, 0, 0, 0,0),(-0.5,0.5,0.1,0.1))
plt.title('Percentage Distribution of Industry Vertical ')
plt.pie(size[0],explode=explode[0], labels=labels[0], colors=colors[0], autopct='%1.1f%%', shadow=True, startangle=140)
plt.show()
# In[76]:
from pandas import DataFrame as show
# In[77]:
## Most Number Of investors
cmi=show(data.groupby('StartupName')['NoOfInvestors'].count().sort_values(ascending=False))
fig=plt.figure(figsize=(10,5))
sns.barplot(y='NoOfInvestors',x='StartupName',data=cmi.reset_index().head())
plt.show()
cmi.head(10)
# In[78]:
## Top Investors
investors = startup_data['Investor_Name']
cinvestors=show(investors)['Investor_Name'].value_counts()[2:]
cinvestors.head(10)
print("Top Investors in Frequency ")
plt.figure(figsize = (12,5))
bar= sns.barplot(x=cinvestors.index[:20],y=cinvestors.values[:20])
bar.set_xticklabels(bar.get_xticklabels(),rotation=70)
bar.set_title("Top Investors by funding on multiple days ", fontsize=15)
bar.set_xlabel("", fontsize=10)
bar.set_ylabel("Frequency of Funding", fontsize=12)
plt.show()
# In[81]:
color = sns.color_palette()
# In[82]:
city = startup_data['City_Location'].value_counts().head(10)
print(city)
plt.figure(figsize=(15,8))
sns.barplot(city.index, city.values, alpha=0.9, color=color[0])
plt.xticks(rotation='vertical')
plt.xlabel('city location of startups', fontsize=12)
plt.ylabel('Number of fundings made', fontsize=12)
plt.title("city location of startups with number of funding", fontsize=16)
plt.show()
# In[83]:
from wordcloud import WordCloud
names = startup_data["Investor_Name"][~pd.isnull(funding_data["Investor_Name"])]
#print(names)
wordcloud = WordCloud(max_font_size=50, width=600, height=300).generate(' '.join(names))
plt.figure(figsize=(15,8))
plt.imshow(wordcloud)
plt.title("Wordcloud for Investor Names", fontsize=35)
plt.axis("off")
plt.show()
# In[91]:
investors = startup_data['Investor_Name'].value_counts().head(10)
print(investors)
plt.figure(figsize=(15,8))
sns.barplot(investors.index, investors.values, alpha=0.9, color=color[0])
plt.xticks(rotation='vertical')
plt.xlabel('Investors Names', fontsize=12)
plt.ylabel('Number of fundings made', fontsize=12)
plt.title("Investors Names with number of funding", fontsize=16)
plt.show()
# From this we can see that India Angel Network,Ratan Tata,Kalaari Capital and Sequoia Capital made the maximun number of fundings.
# In[92]:
investment = startup_data['Investment_Type'].value_counts()
print(investment)
plt.figure(figsize=(15,8))
sns.barplot(investment.index, investment.values, alpha=0.9, color=color[0])
plt.xticks(rotation='vertical')
plt.xlabel('Investment Type', fontsize=12)
plt.ylabel('Number of fundings made', fontsize=12)
plt.title("Investment Type with number of funding", fontsize=16)
plt.show()
# In[94]:
from wordcloud import WordCloud
names = startup_data["Investor_Name"][~pd.isnull(startup_data["Investor_Name"])]
#print(names)
wordcloud = WordCloud(max_font_size=50, width=600, height=300).generate(' '.join(names))
plt.figure(figsize=(15,8))
plt.imshow(wordcloud)
plt.title("Wordcloud for Investor Names", fontsize=35)
plt.axis("off")
plt.show()
# In[98]:
import plotly.offline as py
py.init_notebook_mode(connected=True)
import plotly.graph_objs as go
# In[99]:
temp = startup_data["Investment_Type"].value_counts()
labels = temp.index
sizes = (temp / temp.sum())*100
trace = go.Pie(labels=labels, values=sizes, hoverinfo='label+percent')
layout = go.Layout(title='Types of investment funding with %')
data = [trace]
fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename="BorrowerGender")
# In[110]:
plt.figure(figsize=(8,5))
sns.distplot(startup_data['AmountInUSD_log'].dropna())
plt.xlabel('log of Amount in USD', fontsize=12)
plt.title("Log Histogram of investment in USD", fontsize=16)
plt.show()
# In[112]:
location = startup_data['City_Location'].value_counts()
print("Description count of Location")
print(location[:5])
g = sns.boxplot(x='City_Location', y="AmountInUSD_log",
data=startup_data[startup_data.City_Location.isin(location[:15].index.values)])
g.set_xticklabels(g.get_xticklabels(),rotation=90)
g.set_title("City Localization by Amount LogDistribuition", fontsize=20)
g.set_xlabel("Top 15 Cities", fontsize=15)
g.set_ylabel("Amount (USD) - Log", fontsize=15)
plt.subplots_adjust(hspace = 0.65,top = 0.9)
plt.show()
#Let's create a new feature that is a Amount with log to better see the values distribuitions
startup_data['AmountInUSD_log'] = np.log(startup_data["Amount_in_USD"] + 1)
# In[ ]:
plt.figure(figsize=(14,10))
plt.subplot(211)
sns.countplot(x='Date_month_year', data=df_startups)
plt.xticks(rotation=90)
plt.xlabel('', fontsize=12)
plt.ylabel('Date Counting', fontsize=12)
plt.title("Count frequency Investiments Date ", fontsize=16)
plt.subplot(212)
sns.pointplot(x='Date_month_year', y='AmountInUSD_log', data=df_startups)
plt.xticks(rotation=90)
plt.xlabel('Dates', fontsize=12)
plt.ylabel('Amount Distribuition Log', fontsize=12)
plt.title("Money Distribuition by Month-Year", fontsize=16)
plt.subplots_adjust(wspace = 0.2, hspace = 0.4,top = 0.9)
plt.show()
# In[115]:
startup_data.Startup_Date.replace((['12/05.2015', '13/04.2015','15/01.2015','22/01//2015']), ('12/05/2015','13/04/2015','15/01/2015','22/01/2015'), inplace=True)
# In[114]:
startup_data.head(10)
# In[116]:
startup_data['Date'] = pd.to_datetime(startup_data['Startup_Date'])
startup_data['Date_month_year'] = startup_data['Startup_Date'].dt.to_period("M")
startup_data['Date_year'] = startup_data['Startup_Date'].dt.to_period("A")
# In[117]:
plt.figure(figsize=(14,10))
plt.subplot(211)
sns.countplot(x='Date_month_year', data=startup_data)
plt.xticks(rotation=90)
plt.xlabel('', fontsize=12)
plt.ylabel('Date Counting', fontsize=12)
plt.title("Count frequency Investiments Date ", fontsize=16)
plt.subplot(212)
sns.pointplot(x='Date_month_year', y='AmountInUSD_log', data=startup_data)
plt.xticks(rotation=90)
plt.xlabel('Dates', fontsize=12)
plt.ylabel('Amount Distribuition Log', fontsize=12)
plt.title("Money Distribuition by Month-Year", fontsize=16)
plt.subplots_adjust(wspace = 0.2, hspace = 0.4,top = 0.9)
plt.show()
# In[119]:
from subprocess import check_output
from wordcloud import WordCloud, STOPWORDS
# In[120]:
plt.figure(figsize = (15,15))
stopwords = set(STOPWORDS)
wordcloud = WordCloud(
background_color='black',
stopwords=stopwords,
max_words=150,
max_font_size=40,
random_state=42
).generate(str(startup_data[startup_data['Industry_Vertical'] == 'Technology']['Investor_Name']))
print(wordcloud)
fig = plt.figure(1)
plt.imshow(wordcloud)
plt.title("WORD CLOUD - INVESTORS TECHNOLOGY")
plt.axis('off')
plt.show()
# Plotting Average Year-Start-wise graph for investment in period between January-2015 to Jan-2019 (Annual Starting)
# In[122]:
q=startup_data['Amount_in_USD'].resample('AS').mean()
q.plot(kind='bar')
plt.title('average funding amount')
# In[123]:
startup_data['year']=startup_data['Date'].dt.year
startup_data['month']=startup_data['Date'].dt.month
# In[125]:
fig =plt.figure(figsize=(20,7))
fig.set_figheight
ts_month = startup_data.groupby(['year', 'month']).agg({'Amount_in_USD':'sum'})['Amount_in_USD']
ts_month.plot(linewidth=4, color='crimson',marker="o", markersize=10, markerfacecolor='olive')
plt.ylabel('USD in Billions')
plt.xlabel('Month');
plt.title('Funding Variation Per Month from 2015-2019')
# Companies with most number of investors
# In[128]:
cmi=show(startup_data.groupby('Startup_Name')['numberofinvestors'].count().sort_values(ascending=False))
fig=plt.figure(figsize=(10,5))
sns.barplot(y='numberofinvestors',x='StartupName',data=cmi.reset_index().head())
plt.show()
cmi.head(10)
# In[129]:
def calculate_n_investors(x):#function to calculate record wise number of investors
if re.search(',',x) and x!='empty':
return len(x.split(','))
elif x!='empty':
return 1
else:
return -1
startup_data['numberofinvestors']=startup_data['Investor_Name'].replace(np.NaN,'empty').apply(calculate_n_investors)#removing missing investors and replacing with 'empty'
# In[130]:
n_inv2=startup_data
n_inv=startup_data['Investor_Name']
n_inv.fillna(value='None',inplace=True)
listed_n_inv=n_inv.apply(lambda x: x.lower().strip().split(','))
investors=[]
for i in listed_n_inv:
for j in i:
if(i!='None' or i!=''):
investors.append(j.strip())
unique_investors=list(set(investors))
# In[131]:
investors=pd.Series(investors)
unique_investors=pd.Series(unique_investors)
# In[132]:
investors=list(investors[investors!=''])
unique_investors=list(unique_investors[unique_investors!=''])
# In[135]:
cmi=show(startup_data.groupby('Startup_Name')['numberofinvestors'].count().sort_values(ascending=False))
fig=plt.figure(figsize=(10,5))
sns.barplot(y='numberofinvestors',x='Startup_Name',data=cmi.reset_index().head())
plt.show()
cmi.head(10)
# In[137]:
tp10fund=show(startup_data.groupby('Startup_Name')['Amount_in_USD'].sum().sort_values(ascending=False))
tp10fund.head(10)
# Does Funding depend on the number of investors?
# In[138]:
top10=tp10fund.join(cmi)
sns.heatmap(top10.corr(),annot=True)
plt.title('Corelation Matrix')
plt.show()
# Here,we can see that there is a 23% correlation between the number of investors and the Amount in USD.
# In[139]:
from sklearn.model_selection import train_test_split
# In[ ]: