3731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
vy Uber Business Problem
Uber is facing - driver cancellation and non-availability of cars leading to loss of potential revenue.
‘The aim ofthe analysis is to identity the root cause ofthe problem (Le. cancellation and non-avalabilty of cars) and recommend ways to
improve the situation. As @ resul of your analysis, you shouldbe abl to present tothe client the raat cause(s) and possible hypotheses of the
problem(s) and recommend ways to improve them,
Y_ Import all necessary modules
1 Inport ald the needee nodules
anport pandas 35-96
vernings F1Tterwarnings (“ignore”)
4 heading the dataset in to 2 datafrane of
{4 = parend_cov("s-/inpu/uberarequest-cnta/Uber Request Oata.c3¥")
[Link]()
280 oy 10 TipConpleted —tamaoteer7-—_raaov6 a8
3 asa epot 10 TipCompeted 12772016 7.08 220182208,
4am oy 1.0 Tip Completed 13.07-2018083896 19-072016 08.2547
4 Let's look at the type for each colunn and understand the formatting we need to perform
ae.in4o0
Bats colunns (total 6 columns)
river Se 1985 non
types: Floatet(a), Setst{a), objectta)
¥_ Formatting - Converting Request id and Driver id type to String
fartoRequest $2") = of {Request Sa]. astype(str)
[Link]
Data colunns (total 6 colums)
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true3731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
@ Request sa 6745 non-nutd object
1 Pickup potme GS noncnsl? object
2 Sriver i 12095 non-null. Floste
3 Status Gra3 monenst obgect
4 Request tinestanp 6745 norcmull ebject
5 orap tinestanp 2831 non-null object
types! Ftoutse(a), bject(s)
+ Lets convert oriver 16 also to type string and format “ran” to pd.
a¢T"oniver 26°] = aFT"Driver 36"[Link](str)
aF(-oeiver se"]{ae{"aetver Sa") -e"nan"] = pn
[Link]
Rangelndexs G45 entries, £0 6748
Data columrs (total 6 colums):
@ Request sa Gras pon-asld
1 Plekup point 6745 non-nuld
2 Sriver fe 12985 noncnut?
3 statue 6745 non-ndtd
4 Request thnestanp 6245 noronall
5 prop tinestanp” 2831 non=nul
types ebjectte)
rewory usage! 316.3+ X9
Formatting Date/Time Columns - Request timestamp and Drop Timestamp
1 There are different date fornats fo both Request Tinestano and Onop tinestanp as evident fron the outout below
Aae{ ("Request tinestang™,"Orop Cinestang™ |] -nead(2e)
Aequest tinestanp Drop tinestanp
© tmaoreatst 72016 1:00
4 wmeowerrs? ——sineo%6 1847
3 rampotezto8 220% 22-00
4 1907-2018 089016 13-072016 092547
5 2072016218728 19-07-2016 222860
4072016061522 4-07-2018 071918
7 ssar2o1eostts2 15072016 080752
8 1607-2016 175727 15-07-2016 [Link]
°
simmos6as ——wmra0t8725
10 taraatesce taza ace
41 tamaores290 | raneor6 12:57
42 19.072016 064920 13-07-2016 [Link],
43 1s.0720180a02ss se-0r2016 98:19
4 13.07.2016 142502 13.07.2016 153516,
45 19.07.2018 172918 13.07-2016 182051
46 072016 1201.02 w0r2016 12:9648
19 wraorere4s —sire0r6 19:20,
Formatting - Both columns have dates in different formats. Wrting a Python function and then using the apply function to format these
columns
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true3731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
‘eran convert_sine to fornat the date coluans, This function will fonmat all the dates accordingly
der convert tine(s)
wn serbe)
Se 20000) 4 [25.0,28.8:
ws datetine strptine(s, "Xd/te/2¥ D0)
iF LenGs) tn (28.0)
= [Link](e, Ma-se-Y 29:95")
ase
x = paste saterinet)
+ Lots apply the convert tine function to both the coluens|
4F["orop tinestarp"} = d7{"Orop tinestanp"].apply(convert_tine)
GF{rRequest tinestanp] = df{-Request Cinestarp”]-apply (convert tine)
4 Lets check the type of Both these colums row
ar( "Request tinestano"]-ctyoe, a*["Orap Linestano" ctype
CéeypeC em[as}"), etype("a[ns}"))
¥_ Adding 4 Columns Request¥ear, RequestMonth, DropYear, DropMonth
4 aa these 4 columns for year and month and ensure they are of Integer format
A¢("Requestvear”) = pd.to_daterine(sr| "Request tinestanp"]).dt-year
Ge mequestworen”] = pate daterine(s#{ Recuest Cinestanp"])¢tsnonth
a¢("Dopvear"] = patos
{F("Droponth) = peta
tine "Orop tinestanp"]).[Link]("Ink64")
atetine(af{"Orop tinestarp"]) -[Link]"antea")
1 Lets print the head to ensure ue are seeing correct values for the Request Year/onth and Orop Year/Month colunns
ge oy ante
e Aepent ° Completed [Link] [Link], 6
. cp me nomen ney
1 7 ‘Apert ° Completed [Link] [Link] 2016
2 wor oy 8 gl MRE MERE
adn lun show he Buran eb tp
SASS ESSERE cae te
oN oy oS
1 eer Aepent +2 Completed [Link]
complied Om 1700 09-8600,
[Link]-sort_values(ascendingsFatse) headt)
786 6 days o[Link]
ane: ouration, etyper tinegelta6a[ns)
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true
Drop timestamp Requestvear Request¥onth repvear Drophonth
7 2016 7
1 m6 7
7 m6 7
Drogvear Deoptonth Duration
216 7 osu
2018 7 ogee
ons0:90
cays
2018 7 00
31333731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
# Lets fornat the Duration to show up an minutes and format it as type Float
{fsouration = d¢-puration dt total_seconds()sciv(6®) astype(*Plostée)
df Ouration[ ~é[Link]. isna()] .describe() . ~— "
338 =
Rane: Duration, ctype: floats
Observation-
{Alltips have completed in less than a day With the longest trip being for 01 Hour 23 Minutes
¥_ Adding a column to identify the trips that completed on the same day. The Column name will be SameDay
1 Let's add» coluon Saneoay to understand the trips wich ended in the sate Day
a¢("saneday"] ~ (oa vo_catetsne(a¢T Request tinestanp])-ct-aate pe.to_estetine(3f"Srop thre
anp"1).[Link])
Af, Sanebay value_counts dropra-false)
Af. Saneay dF. Sanebay =
4F-Snebay[ df Sarebay
True] = “Yes
False) =“
react
061 Apo 18 ag Ki MEATY amHETN aay 7 are > eos
1867 Aiport 10 gayi MOBAT ONE aap 1 18 > 500 Yon
2 107 Cy 10 gy -ANEAT IA aONEOTIR sary 7 08 70 en
eran
eros ly tm MOOS HEAT IS ayaa 7 ake No
erat 6752 Airport. ——NOCars 2016-07-15 NaT 2018 7 ce No
era erst cy cue MOCHS AMBETAS gy aaeg a
[Link]
ata colums (total 22 co
@ mequest sa
object
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 4133231724, 10:35AM
Requeet tinestanp
rp tines toe
tequestvene
feucrenonth
Sropvesr
fe buration”
aan
eras
fon-nt
ron
non-nt
ton-nut
2B oneal
non-nt
solution_case_study_8138_LecS.ipynb - Colaboratory
object
object
eatetinee{ ne)
Gatetineealne]
inves
Fonte
object
types: Fleats4(x), Tnest(2), eatetinese[ns](2), Ant4(2), ebject’s)
‘ALL fous 19 Request 14 Colunn are unique
Aar{°Request 26") -unique(). size
stn tere are 2650 Null Driver ids, relating to the trip Request Jds whose Status is “No Cars Available”
dr(-Deaver 14") vaiue_countstérepn
ise)
aF{("Dotver Sch, "Status"]][df["Deiver £d"]-t5na()].value_counts(dropeasFalse)
river f€ states
type: tntea|
‘48 Pickup Point Colum has no null Values ané the Pickup point 4s etther Airport or city
AF("Piekup point” ].value_courts(@ropnaeFalse)
city as07
Airport 3238
anes Pickup point, dtypes Into
GF. eatus value counts(sropnacFalse)
‘rip conpletes 2832,
Ao Cons available 2650
aneetlee ee
Trip Conpleted, No Cars Avatable, Gancelles
‘rt ho WL] Values Sn Request tinestanp coluan
ar["Request tinestang*][of{"Reauest sineseanp”].4sn()]
Sertes((], Mane: Request tinestanp, ctype: datetinesd(as])
snd ro Wt Values
te Oop tanestarp 4s Mull where Status 15 efther Cancelted or No Cars Avatlable
dae{status"T[er( "Drop tinestanp").isna()]-uniqued)
srray({"Canceliea!, “Mo Cars Avatlable'1, type-obsect)
a¢.neaa)
Request Pickup
ia point
0619 Amon
1857 Apo
2 wor cy
Driver satay REQUESE
‘ unestane
to Tie 20160741
Combing 15400
so Tip 2016071
Comps 175700
to Tip 20160712
Comsbies 087-00
sn 1 Trips Requests were nade Sn 2036
print ("Request Year ~ Hof [Link](),*\nRequest Month ~ =, f-OropYear(-[Link]()}-unsque()-astype(nt))
Request Year = (2636)
Request Hontn = (2836)
fre 211 Trip Requests were nade on the aonth of 2Uly
Print("Request Month ~ "of. [Link]()-astypelnt),"\#Deop Month ~ *,[Link]~[Link])) untque()-astype(ne))
Drop
anestany
aoveors
aoveors
1847.00
zore.ort2
09-5800,
equestVear Requesthonth DropYear Oroptonth Duration Saneduy
2016 1 76 7 690 Yee
2018 7 28 7 500 (Yes
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 51333731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
Request Yonth = (71
Drop Meath = (7)
¥_ Adding 4 Columns - RequestDate, RequestDay, DropDate, DropDay
1 Aading 4 Colunns ~ Requestoate, Request0ay, oropbate, Droeoay
s¢(Raquestoate”] = pdato_datetine(ar[ "Request Cinestanp"|).dt- cate
‘e(Raquest0ay”) = pasto,datetine(af{ "Request tinestano"])-dt-day nane()
{¢("Deapoate’] = poto_catetine(4¢ [rap tinestang"}).0t-cote
Att"Dropoay"] ~ [Link](s¢T"orop tinest=no"T) dt -6ay_nane()
sa se A i
Completed — [Link] [Link]
seen soon
17 Aine 18 cgay lie aoe
ve [Link] [Link]
‘ue ie, ten
3 B82 Aiport 18 Gang 2 2 2018
me [Link] [Link]
‘ue ie, en
ow9316 on2547
2016
ao
2010
equestvearRequestronth Dropvear roptonth
7
Duration saneoay
500 Yes
419 Yes
52516607 Yas
‘Adding a column for RequestTime to later on determine the Day Period, such as Evening, Morning, Afternoon, Night etc.
4 saaing a colunn for RequestTine to later on detennine the Day Pested, such as Evening, Morning, Afternoon, Night ete
ae("RequestTing”] = pd.te_datetine(et[ "Request tinestanp"] dt. tive
¥_ Adding column TimePeriod
‘nazing Colunn TinePentod
nport datetine
{a¢("TanePersog") ~ pant
betwoon([Link](7, 0,
[af{*Requesersne"] between{datetine-tine( 36)
[af{cRequserine"| between([Link]( 38,
[af{sRequestrine”] between([Link]( 26,
[Link]
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true
[ar {*aequestrine"].between{[Link](4,0,8), [Link](6,$9,58), inclusive = Teve) =
1), [Link](,58,58), inclusive = Trae)
botween(daterine tine(32,0,0), [Link](26,59,58), tnelusive
0), datetine tine(27, 59,59), Snelusive
0), datetine-tine(:9, 59,59), snelusive
0), datetine,tine(23,59,59), Snelusive
G¢{"TunePerioo” (of "Request Tine"].betneen(datetine. tine(2,0,0), é[Link](3,59,59), inclusive = True) == True) =
True) =
rue)
= Tee) =
request:
2016.07
oer
rover
True) = "83 Afternoon
trae) 1 True] = "es Early Bvening™
True) = "06 Night”
61333731724, 1035 AM
o 68
3202
4a
Pickup Driver
Aipor 10
‘Aipon 10
cy 10
Ripon 10
cy 10
Hp
‘Comps
we
‘comple
completed
wi
Comps
¥ Adding column RequestHour
1
201607
9.17.00
2m16.7
20800
a
solution_case_study_8138_LecS.ipynb - Colaboratory
fl
21607.
9:58.00
amie.
220900
a
Requestvear Requesttanth DropYear_roptonth
2016
2016
2018
aF(rRequesthour”] = pate datetine(ar[ Request tlnestanp"])-at-hou
[Link]()
ia
2 1607
3 ate
point se
Aipon 40
oy 10
Alpen 10
¥ Adding column DropHour
A¢("Dropsour") = pasta cat
Fs neaet)
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true
‘Compleat
tH
competed
wip
Hp
‘completa
ie
‘competed
‘inestonp
srst00
201607
rsr00
vci790
2
20160.
ows:16
tine(a["Orep tinestang]) ét-hour. ast
nesta
‘0000
aso.
swer00
98:00
2
am6o7-
9.2847
2018
2016
2018
2018
ao
2016
a8
orephonth
90
210667
uration
410
550
2016-07
2016.07
2016-7
2016-07
2016-7
11933731724, 1035 AM
equst Piap Brier gegegg _REQUHE Bop
id point id "= tinestanp timestamp
vip 201607. antear-
FT re a
a 1 2016 7 00
Comoe nszaa tearan
ip 2607. 201607
a a eh i a 7 am 7 40 ve
melt os700 085000
ip 2607. 20160
32582 Aiport 10 cag de Toto 7 2016 7 550M
ised arog) 220800
we cy tw My ET, HET “
ee en Sat 7 2016 7 eestor x
Milestone - Data cleansing seems to be complete at this point
¥ Analysis begins
pe. pivot, eable(datandt,inder="Pickup point" ,colunnss"Statut"valuese"Request 40° aggfunc-"count")
Status Cancelled No Cars Available Top Completed
Pickup point
Airport, 198 ws sar
ity +068 sor ‘508
Creating a pivot table - pickup_vs_status to compare the number of requests by their status from each pickup point and plot
‘bar graph
4 Lets nane this plvot table as pickyp_vs_status
Dickop_vs_starus © pd.pivot_table(astacelingexe"Pickvp potnt”, columnse"Status" valuese"Request 14" agpfunce"count")
[Link]( ((font-fanslyssans-rers¢°0))
[Link][“[Link]") = "Open Sane"
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true
equestvear_Requesttonth oropvear OropMonth Duration SancDay RequestDs
2016-07
aneor
2016.07
ore?
81333731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
+ comparison of nunber of requests fron both sources (Airport and city)
res = pickup_vs_status.plot(kinds"bar',,statkedetrue, igsize=[25, 10], colornap= Pair
[Link](-conparsson of nunber of requests fron both sources\n",fonesize-25, le
fontsize-20)
7 fontaeighte"bol a")
[Link]("nPickup potnt",fontsizes20)
pit. setp( resuxaxis.get_majortickiasels(), rotati
pltiylabel(“Trip requsis\a",fontsize-20)
pit. setp( [Link].get_najorticklabels(), rotati
ge’ pie -Legend(titles"Trip status® title tontsizes20,10c~'apper center", boox to_anchor=(2.2, 2), shadow=Trve, ncol=t, labelse[ Cancelled”
‘or 9 in resepatches
vet, Retant » 0.
Bey = peat ay)
es: text(iieth/2,
on
"(Lae} Format hetent),
horizontataLignnents" center",
verticalalignnent="ottor', fontsize-20,coler='w")
[Link](“b1 - Congarison oF nunber of requests fron both Sources. jpeg", Gpi=t00, box extra_artist
pit. shout)
Mist, poget_nedgheo)
1a), Bbox_snches="tgnt")
Comparison of number of requests from both sources
ood Tip Status
emt Canceled
fm vocarenvatabie
=a ‘Completed
2500
3
3 2000 ies
om
7
foe
ES
5 azn
rr es
Pickup point
‘Observation 1 - Trips requests from the City has higher number of cancellations compared to the one's starting from the Airport
‘Observation 2- Trips requests from the Airport register higher number of No Car Availability compared to the one's requested
from the City
Observation 3- Successfull rips originating is slightly higher from the City compared to the Airport
Creating a pivot table - hourly_requests.vs_sickup to analyse number of requests each hour from each pickup point and plot
bar graph
+ Lot's create a pivot table hourly_requests_vs_pickep for all trips fron Airport or City to understane the Status of these requests per hot
hourly_ requests ve_pickup = pe,pivor tabla datandf,sndoxe{“Requestiour"],colunnse("Pickip point J,valuese"Reauest 18” agafune="coune”)
hRourly_requests_vs pick -heoet)
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 91333731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
Pickup point Airport. city
Requestiour
° 248
2 “8
3 “4
4 nom
4 Let's plot 2 bar chart for sll trips from Airport or City to understand the Status of these requests per hour
[Link]["[Link]") = "Open Sans"
es = hourly-requests_vs_sickup.plot(kind="aar’, stacked-True, figstze-[25,8),colomapo"Pasreds,fontss20-20)
[Link]("hinber oF Requests from Alepore/City Per hour\s"sontsizee25,fontweight="bold”,20t="LeFt")
pitondabel(“\ntequest Hour, fortsize=20)
it. setp([Link],get_najorticklabels(), fontsize=20,rotation-®)
pitiylabe1 “tuner of Tip Recuests\n*,fonesizen2
setp(r
ge = pit. legend(tisle= Pickup Point, title fonesize-18, loc="upper center", sboK te anenore(1.05, 1), shdowsTrue, neolet, labelee(“Alnpore™
wath, Refent = puget nidth(), puget_nesehe()
my popet ay)
Fas: text(seth/2,
on
"(0 formatchetaht),
horizontalalignnert=' center’,
vverticalaligment="otton', fortsize-15,color='w')
Nianer of Requests fran Ainpore-Cisy Per Hour Jose”, pint, bbox_extra_arcistsn(
it
pt. showt)
as), box inenese' tant”)
Number of Requests from AirportiCity Per Hour
Number of Tip Requests
(Observation 4- Number of Trips Requests is higher from the Airport during the Early Mornings(4-6 AM) and Momnings(7-11 AM)
‘Observation 5- Number of Trips Requests is higher from the City during the Evenings(5-6 PM) and
(7 PM- Midnight)
Creating a new pivot table trip_completed which will show the total number of successful trips from Airport and City per
hour
# Lee's create pivot table for all canpeted trips fron Alrgort or Clty per hour
trip_conpleted = pa. pivet_table(datasdt[at-statuss--Trip Completed”, index=["Requestiour”], columns “Status”
chap plat" ],valuess"Request
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 101333731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
4 Let's plot a bar chart for all cowpleted trips ¢ron Airport or City per hour
res = trip_conpleted.plot(kinge'bar’, stackedeirue, figsize=[25,8],colornape"Paired", fontsizest2)
[Link] hunter of Conpleted Trips fron Airport/City Per Hour\n" font size-25,fontueignt="bold”Loce"Left")
pit adabel(“\ntequest Hour”, foressze=20)
pit-setp([Link]. get najorticelabels(), fontsizen20,rotationa®)
[Link](*aunber of Trip Reguests\n",fontsize=22)
pit. setp([Link].get_aajorticelabels(), fontsize=20)
ge = pit. lagend(title~ Pickup Point" title fontel2e-35,loc-'upper center", Wbox te anchor=(1.85, 1), shadow-True, ncolst, labels-(“ALnport®
‘for 9 in resepatches
Wet, Retent = p.get_wigth(), paaet_netghe()
Xe v= peBet V0)
Feescext(imieeh/2,
ws
"Lary Format heteht),
horizontataLignnenta' center’,
verticalatignnents’bottor’,fontsizes15,caler="w")
[Link](“e3 - Numer of Completed Trias fram Alrpoct-City Per Hour. jpeg” dpi-499, boox extra artist
pit. snout)
8)» Bbox_snches="eight")
Number of Completed Trips from AirportiCity Per Hour
Number of ip Requests
Observation 6 - The heaviest load was during the Sth hour of the day during the week. This time period has total successful
requests of only 185, The total number of Drivers is 300.
‘This basically means that there are free drivers and cars available at this time but are either cancelling the requests or not
taking any requests for some reason
[Link]
equers Pickup river —eatus ROGUES OTOP Requestvear Requestianth DrapYear Oraphonth Ouration SameDay RequestOs
ia "poise sa ‘inestang timestamp" ea rear oropont yea
tp 1607. 2016-07-
ee " nl 2016 7 208 7 699 Yes 2016.07
rpited 5309 190000
4887 Aiport 4.0 Gay le 1 206 7 206 1 00 Yes 201607
Somsted — srsr90 1847.00
yp 201607. 201607-
21807 Cy 10 Caml 2 2 2016 7 26 7 ao Yen pater
21700 osse00,
vip 201607. a0160r-
2252 ipod 10 aay te coro 7 me 7550 Yon aot
‘" [Link] [Link]
6a ey 10 gli tote 7 mer sasteesr Yee 01800
“ o[Link] [Link]
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 11383731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
Creating a pivot table -to plot a bar graph for number of requests during each time period of the day, such as ‘Morning,
Evening, Afternoon ete”
4 Let's create a bar chart for all trips frou Aleport or City based on Tine period such 25 Early Horning, Horning, Afternoon, carly Evening,
res = pé.ptvot_table(dataede ndexe[“TinePerioc”,columase"Plckup point” ,valuese"faquest id", agefunce"count"),90t(kinde'bar’, stackedeTPvey
[Link]([Link], get masorticelabels(), rotetion=45, onestze=34)
[Link](*hinter of requests auring each tine period of the day fron Airport and City" fontsire~25,0e="Ief%")
for p in res-patenes
‘ath, nefent = puget width(), puget_neSghe()
my popet ay)
Fas, text(seth/2,
w
"(0 format hetght),
horizontaleLignnert=" center’,
verticalaligient=sotton',fontsize-28)
[Link]("B# - Nander of requests during each tine period of the éay fron Airport and City-dpea" dptndao)
pit shout)
Number of requests during each time period of the day from Airport and City
“af
¥_ Hour wise comparison of trip status per hour from Airport and City in 2 separate bar graphs below
1 Let's plot hour wise comparison of per hour sunber of requests based on their Status fron Alrpo
res = pé.pivot_table(datarde[or{ "Pickup point” Jo="Airgort],lndexe[Requesthour” ],columse"status",valuese"Request 1d", 2ggfunc=*{25,26))
‘es = [Link](hues"Pickip point”, ye"Requestiour”yxe"Status”,datandf,palettes"Paired”)
[Link] fox plot per hour ‘von Airport and City", fontaizesdS, loc="Ieft")
pit adabel “Pickup Hour”, fontsizen20)
pit. setp [Link].get_eajorticklabels(), rotation=b,fontsize=22)
[Link](“Tria requsis\a",fontsize=20)
pit. setp( [Link].get_najorticklabels(), rotation-b,fontsize=20)
1ge = pit. legend(titlen"Picup Point, locr' per right’, box to_anchor=(1.12, 1,82),shadoweTrue, ncole1, labelsn[‘Aleport?,"City"],fontsize
[Link]("07 - status fox plot per Hour fron Airport and City. Jpee", dpinade,bhox extra artistse(]ge,)_ baox inchese Tight")
Spit. saverig( "east [Link]", opi-258)
° =
From the above visualization, we can see that the number of cars is not available between 7 am to 2 pmin the city and the
airport between 5 pm to [Link]. of cancelled cabs in the city are happening from 6 to 9 am and in the aisport between 1 to 8
pm,
‘Day wise comaprison of trip status each day during the week. One bar graph each for Airport and City
# Let's create a bar chart to conpare nip Requests by Status for each doy from Alnport
res = pdapivot_table(datandf[ef[ "Pickup point” JoAirgort”], ndexe["ReguestOay"],coluarse"Status",valuese*Request {d",apefunce"count") plot
res. set_facecolor(*Lignteray")
[Link](*Pickup Hour fontsize=20)
it. setp( res xaxis.get_eajorticklabels(), rotatios
pitiylabel “trip reqests\n",fortsize-20)
[Link]( res.yaxisigat_sajorticklabels(), retationeb,fontsize=70)
[Link]"vay wise comparison of Trip status fran Airpore\n",ontsize-28,20¢="iefe")
ge = ple-tegend( titles Trip Status", loce"upper canter", bbox”toanchora(I.2, 1),shadowsToue, acolat, Isbelset "Cancel
wath, notant =
wy poset ey)
[Link]/2,
‘yshelare
"0 format hetaht),
horizontalelignnert~' center’,
vverticalaligient=otton’,fontsize-28)
[Link](“BH - Day wise comparison of trip Status foon Airport. pe
pit shout)
fonesize-20)
5 No care Avattaat
et wlan, poget_netghtC)
dp nao, boox extra artists(1g6,), box Lnchese' tight")
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 141333731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
Day wise comparison of Tip Status from Airport
700
sm cancelled
lm No Cars Available
mmm completed
‘Tip requests
Monday Thursday. Tuesday Wednesday
Pickup Hour
4 Let's create a bar chart to compare Trip Requests by Status for each day fron City
res = pdapivot_table(datacde{ef[ "Pickup polat”J="City"], edexe{"RequestDay”),colunns="Status" values
es. set_faceceler(*Lightyellow')
pitodabel(“Pickap Hour” fontsi22=20)
pit. setp( [Link].gat_najorticklabels(), rotation
pitiylabel(“trip requests\n",fortsize=20)
pit. setp( [Link].get_azortickiabels(), rotation
Plt titte("Day wise comparison of Trip Statue fram City", fontsize28,Toce"Ie¢*)
Age pit tegend( titles Trip Status" 1oc="upper center"
Wadi, nelgnt =
wy poget yO)
Fess text(seth/2,
‘pshelane,
"C009" fornat(hetaht),
horizontalalgnnent=" cents
vverticalaligment="sotton',fontsize-28)
[Link]("®8 - Day wise conparison of Trip Status fron City. Jpeg” épintoe,bbox_oxtra_artistse(Igd,), bhow_inchese'tight")
[Link]()
Request Se", aggfune="count").plot(ese
box to_anchor=(2.2, 1),shadow-Toue, acol-1, Isbels=t"Cancelled", “No Cars Avat2ab)
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 181333731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
Day wise comparison of Trip Status from City
293 339 rene
320 se cancelled
ws 279 fm No Cars Available
273 mm Completed
600
500
g
3 400
g
F 300
200
100
or Friday Monday ‘Thursday —=sTuesday Wednesday
Pickup Hour
Performance of Trips based on Status is almost same each day
¥_ Creating a pivot table - sd to analyze supply and demand
set's crente a pivot table to understand the supply derand ger hour based on Status from Alrpor® and City
f= p.plvot_table(satardf, Srdexe["Requesthoun®, "Pickup point” ],calumnee"Status"values~"Request 14" SEB"Gne~'count” narains-Tove margins.
34. fina(@,irplace=True)
‘Sa{"ManceT ted" -a0at [Cancel ed" }/sd-A11
Sal"mocarstvallable"]-100r0d["No Cars Avallable"|/sd.A11
sa["Monpletee”Javetsdl "Trip Conpleted"]/+4.43)
14,rop(colunns=[°ALL"]Lnplace-True)
[Link])
‘Status Cancelled No Cars Available Trip Completes XCancelled MoCarsivallable Completed
Requestiour Plckup point
° Airport, oo 300 230 0.000000 sea0orrs «3.206226
cy 30 20 sro asairs8 sesoi7ae asses22
1 Airport, 00 20 sa a.o00000 sn.oa7619 0.952381
ty 40 20 r20 aanasee 2:790698 27. 906877
2 ‘Airport oo 250 ss0ac00000 sns7seto 29004300
Bar graph each for Airport and City and compare supply (% Completed) and demand(% Cancelled + %sNo Cars Available)
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 161333731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
‘tet's create a bar chart to understand the supply devand per hour based on status from Airport
rer = séoee("Alrpors",levele2) Sloe[@s,:]-plot(kine'oar", stzekedeirue, figsizes(15,28],colommape"Paired”,fontsizee12, sharey-1rue)
[Link]([Link] najorticelabels(), rotation=9® )
fen set farecoler( ightersy”)
[Link](“\nPickup Hour”, sontsize=20)
pit. setp( [Link].get_majorticklabels(), rotations
pitiylabel("Munver of Teip necuests\n",fortsize=22)
pit. setp( [Link].get_najorticklabels(), rotatio
PIt-titLeC“Hour wise comparison of Trip Status #ron Alnport\n",fontsize-20,10¢="left)
ge = pl Degend(titles'Trip status’ 1oce"upper center", boox_to_anchora(2,16, 1.015),Shadov=True, ncolel, labels "ACarcel ee", "20 Cars #
[Link]("2@ - Hour wise comparison of Trip Status feon AInpOre. Jpeg” ,cpind0®,poox_extra_artists(IgH,}» tbox inches 'tighe")
pit. shout)
Hour wise comparison of Trip Status from Airport
Sm %cancelled
SS %No Cars Available
mE %Completed
Number of Trip requests
0 1.2 3.4 5 6 7 & 8 1011 12 13 14 15 46 17 48 19 20 21 22 23
Pickup Hour
‘tet's create a bar chart to understand the supply devand per hour based on status from City
ros = sdoxs("Chty"evelet) $20e[@:, 3] plot (kind true, figstze-[25,18], color
[Link]([Link], get najortieelabela(), rotation420 )
Pes set_facecoler('Lightyellow)
pitadabel(“\nPlckup Hour” fontsize=20)
pit. setp( [Link].get_najorticklabels(), rotationsb,fontsize=22)
pitiylabel("aumer of Trip Reeuests\n*,fortsize=20)
pit. setp( [Link].get_najorticklabels(), rotation-b,fontsize=20)
pitveitLe(“hour wase comparason of Trip Status #ron City\n" ,sontsizes20,1oc="left")
ge = pit Tegend(titles'Trip sestus'loce'upper center", bbox_to_anchor=(2.16, 1.015),shadow-True, ncol~1, labelse[ "Marcel lee", "20 Cars #
[Link]("21 - Hour wise comparison of Trip status fron City. Jpeg" dpindee bbox_extra_areistse(lee,), bhox_ancnese tigre’)
pat. shout)
Palved”,fontstzec12,shareyetrue)
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 111833731724, 1035 AM
100
Number of Trip Requests
20
°
solution_case_study_8138_LecS.ipynb - Colaboratory
Hour wise comparison of Trip Status from City
0 123 45 6 7 8 9 1011 1213 14 15 16 17 18 19 20 21 22 23
Pickup Hour
jm %Cancelled
lS %No Cars Available
mE %Completed
Creating a pivot table -trip_duration to compare the number of requests by duration/distance(Closest,NearFarFarthest)
from each pickup point and plot a bar graph
set's create 3 pivot table to analyse duration of all completed trips (where Duration is rot null)
lration = df[["Requestiour", "Duration", "Request id", "status", Pickup point"]]{ (oe bration. isre())]
ts
‘trip. aunatton-neast)
equestiour
2 so
2 sso
4 8 sastecer
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true
Duration Request $4
‘907
asa
one
status
“Tp Completed
“Tp Completed
‘Tro Completed
‘TH Completed
‘TH Completes
Pickup point
Aiport
Aiport
iy
Aiport
cy
181333731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
‘set's create a bar chart to analyse the wakinin duration of all completes trips (ahere Duration 4s not null) fron Airport on cSty
res = pé.pivot_table(datartrip_duretion,index="Requestour",colunms"Piceup point" valuese"Duration”,aggvune="Wax") -plov(cinésoar", stackee
[Link]([Link]. get najorticelabels(), rotations2® )
pit adabel(“\nPickup Hour”, ontsize=20)
pit. setp( res-naxis.get_najorticklabels(), rotationsb,fontsizen2@)
[Link](-Duration of Tripte",fantsize-28)
Plt. setp( [Link].get_sajortidklabels(), rotationeb,fontsizes22)
put. tite(*karinun Duration of Teips fron Airport and Clty\n",fntsi2e-20,2oc="LeFe)
ge’ = plt-Legend( titles Pickup Point’ 1oce"upper center", Boox £9,anchora(2.2y 2), shadowetrue, cole
‘or p in resepatches
Width, netant ~ puget_width(), puget height)
Bey peattay0)
es text(ineth/2,
w
F(Lae} Format helene),
horizontataLigments" center",
verticalalignnent="ottor', fontsize-1s,coler="w")
[Link](“Z2 - Maxinun Duration of Tips fron Airport and City. pes".
pit. shout)
abelse["Airgort', "city" ].fontsize=ze
tox extra_artistso(1gs,),, boos tne
oxime Duration tips om Apert an Cy
=o
tue Hour
‘iets create a bar chart to analyse the mininun dunstion of ail completed trips (ahere Duration {8 not null) fron Airport oF City
res = pd.pivot_table(data-tedp_duration,index-"Requesthour",columse"Pickup point" ,velues--Duration”,aggfuncs"ain) plot(kinds bar", stackee
pit. setp([Link].get_najorticelabels(), rotation=0® )
pitoxdabel(“\nPlekup tour ¢orest
lt. setp( resvsaxis. get najorticklabels(), rotatione®, fonteize=20)
pitiylabel(“Durstion of trip\r", fontsize-28)
pit. setp( res-yanis.get_sasorticelabels(), rotation-b, fontsize=20)
[Link](-kininan Duration of Trips fron kirpor® and City\n",fontstz0-28,20¢="Lefe)
ge = pit. legend(sitle~Pickup Point", loe="pper center”, bok t0_anchar=(3.2, 2) shadewsinve, neol=
for p in reseputches
wath, netent
wy pone ay)
Fesrtext(xandeth/2,
on
"(5:00)" fornat(hetaht),
rorizontalalignnert=centen’,
verticalatigment="otton’,fortsize-15,color="w")
(+ Mininus Duration of Teipe fram Airport and City. jpeg” ,dpind00,bhox extra artist(2g6,), tox neh
abels-["Airport', "ity" ], fontstze=7e
get adth(), poget_pedge()
it show)
inmum Duan fips rem Riper andy
osuuaees
q
Creating a pivot table - sorted_df sorted on driver id and request timestamp.
‘Then comparing the gap between each request and the location from where the next trip started for the driver
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 191333731724, 1035 AM
‘And making observations based on that
1 for this First lets sore the data on Driver 14 and Reque
solution_case_study_8138_LecS.ipynb - Colaboratory
nestanp
sorted_6f = of{-[Link].157a()].sort_values(by=["Oriver 1d", "Request tinestang")})
Sorced_#[Link]()
1 eer
4a
Alport
oy
ty
°
wy mee
Compt a
te
como
ie Ber
compet poet
Compstat 1a
2m1607-
fH
2607.
220300
a
# Next, we WiLL use the shift{-1) Function to Fetch the next cow
sorted df["Driver
Sorteddf["Pickup point oext™]
Sorced_ "Duration next
sorced ef
Period. nex
Sorced_at{"Reqvesthou
5 sorted de["Driver "J shiee(-a)
sorted. df{ "Pickup point” Js
Sorted_{ "Reauest tinestanp_rext”]
~ sortes_of[ Duration") shife(-1)
[Link]{"ReqeestOny hex
[Link]{"Reqvestiour next] = sorted df
Sorted f["ReguestDate_next”] = sorted of["RequestOat
sorted [Link]()
o 68
3 2512
10
Sorted df = sorted de[{ Request Ld°,"Oriver 1d" "Driver 14 next", Pickup point”,
‘pot
Arpt
Aiport
» sortee_de["TinePerioe
next] ~ sorted. af "RequestHour"].shift(-1)
= sorte. df "Request ay
Aiport
oy
oy
port
snieetay
shares)
Requestvear Requesthanth DropYear_oroponth
206
2016
(1)
Sorted of{ "Request tinestang" ]-shiet(-1)
astype("Intse")
Donte)
2016.07.
0931790
2
Sorted_at{sorted_éf{"oriver 16") I= sorted df["Ortver ext]
zoreors2
09:17.00,
zor6ors3
218728
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true
2016
2018
2010
2016
500
52510667
7 699 Yee at807
7 52510667 Yes 2016-07
quest tinestane
02Memng
Evenng
05 Nght
2 Mamag
04 arty Evonng
2 Momng
02 Momng
05 Noht3731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
8 exes 100 yin attr ag 80
sae 1001000 Aor oy NE MEE ase a0
20tear- 2016-07-11
esses ‘eanc0
2o1eer
er coe 10101020 cry pen GamNb OMY space oro
aves
set 670610201080 Arpot Argon 13 169732 ot seee67 sto
sas ees 550060 typos ts NBO sag sso
221021 05.25.00
2016-7. 2016-07-11
356198 660970 pot ipa TMG aa aac oro
ou esrt 70 980 type ass no
956 6252 8.0 999 City Airport 15, 2016-07-11 45.309333 610
[Link] [Link]
2orecr
avaot
on ay
Evening
on Ey
5 Nott
6 Nght
5 Non
on ea
Evening
05 Nght
os Evening
02 Mecring
2 Meening
03 Atemoon
ary Maening
2 Meering
ary Wemnng
01 ary Moring
“There are 300 such rows, after which there is no more request fo each diver. Which makes sense as the total numberof unique vers for
‘this datas 300
sorted ("waiting") = 8
Sorced_of tasting. value_counts()
‘for indexsrow in sorted_of{{*waiting")][sorted ét{"Oriver id") = sorted_df{"Oriver id next")).tercows()
sorted. df. at( index, "waiting )-"wattine
sorted at {{"Waiting")][sorted_¢f["Oriver 46] f= sorved_af{"oriver i¢ next] value counts()
waiting 300
sorted_#f kasting.value_counts(dropes-Flse)
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true
211833731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
ssorted_o¢["watting"I(-(sorted_d¢T"RequestHour"] =~ sorted_d¢{"Requestiour_next"1)) & (sorted ¢f{"Driver 16") =~ sorted_df{"oriver id next
for indexyrom in sorted @f{{-watting"]]{(c(orted,df{-Requestiour"] == sarted_df{"RequestHour_next"])) & (sorted ef{"Driver {e"] a= sorted. ¢
sorted [Link]{index,"waiting")="walting”
ea df[ "Waiting" }(-(sorted 4F[ Requestiour"] a= sorted de[-Requesthour next) & (sorted df"Oriver Sa] ae sorted de["Deiver fd_next™)
Waiting 1310
Please note that the Waiting indicator does not simply mean the driver was realy waiting. It means that either the driver was
‘waiting or used other channels to get customers but didnt use the Uber platform to accept the next ride, This will help us
determine how many such drivers were available each hour and compare it against the demand and failed (Cancelled or
Unavailable Car) requests
[Link] (sorted. of astings"initine
1 201607 2016-07-92 04 Early
[Link] =vening
2 tor 010 yin aatbarse ay 550 c2Woring ce it
onao
i
2016-07. 2016-07-13
csaeie
2otecr :
1 sto 1010 pon cty IG aat8rS sg se S1EBY ox cay Evening
[Link] s
ores
050800 o7s9.00 joing
esa soo 00 typename sso OE i
sort Ercan
oer e020 apo cty 5 NBT so ateser—[Link] co Mamig
see esi 500 ma Aiport var 8 ues so
We have a total of 1610 rows where the driver didnt accept a request when they were inthe location but chose to either wait
or got customers from other channels
Plotting a bar graph to show how many drivers are not accepting a request or accepted a customer thru a different channel or
‘simply decided to wait but not accept a request
For simplicity, there is a column name “Waiting’ to explain such scenario
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 221833731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
res = pé.ptvot_table(datarsorted_df{sorted_dfwattinge="kaiting” I, Inéex-"Requestiour",colunns~"Pickup point” ,values-"watting”agefunco"count
[Link]"hunier of Drivers waiting at the Airport/City Per Hour but not aecepting ot cancelling requests or sing other channels\n", fonts
[Link] “\nfequest Hour, fonesize=20)
pit. setp([Link], get najorticelabela(), fontsizee
pitiylabel Chanter of Deivers\e"fontsizee20)
pit. setp([Link]. get majorticklabels(), fontsize=20)
ge’ pie -Legend(titie= Pickup Point’ title sontsizes15,20ce"upper center", thox to enchor=(1.05, 1), shadoweTrue, acolet, labelse[*Airport*
‘or 9 in ressprtches
Wet, netgnt = [Link] width(), p.get_neighe()
Xe v= vege V0)
ees sext(ineth/2,
we
"CLaeY format hetght),
horizontatalignnent="center”,
verticalaligarenta Botton’ fontsizent5,colore'w")
pitasavettg(-28 - Nawer of Orivers wating at the Aleport or Clty per Hour but nt acceptiog oF cancelling requests oF using ether channels
pit. shou)
rotations)
Number of Drivers Waiting at the Airport/City Per Hour but not accepting or cancelling requests or using other channels
hourly [Link] status = pénpivot_table(datandf,indoxe[Requestiour"],colunnser"Status"T,valuese"Request 46", aggfuné
hourly_requests_ve_stater.nebe()
court")
Status Cancelled Ho Care Avaliable Trip Completed
° a 58 0
4 ‘ 86 2s
‘ 5 ”
res = hourly_requests_vs_status.plot(kinée"sar*,stackedeTrue, figsizes(25,1
[Link](“Trip Request Status Per Houn\n,fontsize=25, fontweight="bolé", 10
pitondabel(“\nfequest Hour”, oresizes2)
pit. setp([Link],get_najorticelabels(), fontsize~
pitiylabel(-Munaer of Triprin®fontstze-28)
pit. setp(res-xanie. get najortscelabela(), fonts tz
ga = pt -2egena(titles status’, itie_fontsize
‘for p in resepatehes
Width, netent = [Link](),
wy pope ay)
Fas, text(iweth/2,
We
P(E00) fonnatthesens),
horizontalalignnent="center’,
verticalaligment="otton', fortsize-15,color="W")
pitsaverig("25 - Irip Requests Status per Hour. jpeg" dpindd0,bbox_extra_artistas(Igd,), bbow_snchese"tight')
pit. shout)
| colornape"Paives"fontsizeet2)
er)
rotations)
>
5,20cs"ypper center”, box to. ancher= C2
2.638), shadoweTrus, ncol+t, Labels-["Cancelted”
get nesghe()
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 23193,3731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
‘Trip Request Status Per Hour
8
:
i |
request Hour
Analyzing different types of Trip Distances that were successful
Closest, Near, Far and Farthest (not an indicator of distance but duration) are just used for simplicity to depict the kind of
distances that are more acceptable to drivers
4 Let's look at the duration colunn and see the nunber of trips baseé on certain bucket of Durations. Like guration less then 30. setween 38
4¢,ounation| ([Link]<38)].size, cf. ouratton{(¢.Duration>-38) & ([Link])] size, @f,Dunation[([Link]>-4S) & (af. uratton<68)
can, aa, 938, 572, a7)
4 Lot's add a colunn for these Suckets. so will call 4 Distance Estiator for row
ar("asetancetstinator"] = pan
1 Aad now lets create the buckets
aF{"osstancetstinater* [ef Duratione3@} = "et Closest
dar(-Dsstancerstinater*][(4¢.Duration=38) & ([Link])] = "82 Near”
Gr("Distancerstirater*]|(4¢-Duration=4S) & (@[Link]ée)) = "83 Far
de(rDistanceestirator*][ (Ge Guration»=s6)) = “Bt rartnest™
A¢("Distanceestinator*] value_counts(deoprarralse)
G1 Clorest 10
Naver Distencetstinator, ctype: sntse
4 Noe Lets create 2 pivet table to see the munter of completed trips from Airport and City and see how many of these fal1 in each Ouration/t
a. plvot_tabie(datasdt,indexe"Plcvup poune”,columse"Distancetstinator®,valuese Request 14°, aggtunce"count”)|
Distancetstinstor el Closest 02 Near 03 Far 4 Farthest
Pickup point
Airport, 409 a8 3
cy e422 09
Plotting a bar graph to show the type of duration that are successful
Generally the duration of requests that are least in service that are closest. Far and Farthest duration/distance seem to be more
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 241933731724, 1035 AM solution_case_study_8138_LecS.ipynb - Colaboratory
4 Now Lets create 2 bar chart to see the nunber of completed trips from Airport and City and see how many of these fall in each Duration/Dis
res = pé.pivot_table(dataedf indexe"Pickup point” colunse"Distanceestinator” valuese"Request io", aggrune=" count") plat (kinde"ear"Figsize=[
[Link]("irip Requests Basee on Distance or Duration, fontsizee25, fontweignt="bole,Toe~"Ief*")
[Link] (“Pickup Point", fontsize=22)
pit setp([Link]. get najorticelabels(), fontsizen20,ratations®)
[Link] “Minder of Trips Conoleted\n" fontsize=20)
lt setp([Link].get_aajorticelabels(),fontsize=20)
[ge = plt-degend(titla= Olstance or Ouration Indicator* t8tle_fontsize-15,20c~"upper center’, bbOx_to_anchor=(L.A5, 1.88), shadow-True, neo}
‘for 9 in resepatches
Sian, etent =
wy pepet ay)
reps cext(iieeh/2,
we
FELary Format heteht),
horizontatalignnents"center",
verticalaliginents’bottoe’,fontsizes15,calers"w")
pat. saverig(“36 - Trip Requests Based on Olstance or Duration. Jpeg" dr
pit. snout)
get patent)
cL HIENO,
5 Boox_extra_artists-C1Bd,), Sbox tnches="eight!)
‘Trip Requests Based on Distance or Duration
Distance or Duration Inceator
‘es Cosest
ee Near
uo | = fer
farthest
Number of Trips Completed
g
‘Airport ‘city
Pickup Point
‘Similar bar graph but this time based on each hour
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 25193,3731724, 1035 AM
solution_case
tudy_B138_LeeS.ipynb - Colaborstory
4 Now Lets create 2 pivot table to see the number of completed ‘ oe ee °
0 20 40 60 80 160
‘%6Cancelled from City Across all Drivers
secancelled || pp rn °
° 20 40 60 80 360
Creating a pivot table - supply demand_gap_aitport to plot a graph on success vs failure
4 e sou that sore drivers wore nto accepting requests at all on his route and had 188% cancellation
4 So Jets Look at the supply demand gap nore closely than we have before
4 Lets First Look at the demand supply gap for Airport ané creaye a pivot table for tt
supply_enand_gap_Airport = po,pivot_table(dataruber_final{uber_final( "Pickup point" ]n-"Airport”},Andexs*TinePeriod" colunnse"Status” values
Supply_éerand_g3p Airport neae()
Ssupply_éenand_gap_Airporti"ratlea"] = supply denand_gap_sirsort( Cancelled") + supply_serané_gap_Aisport["Wo Cars Avai2sble"]
Ssupply_enand_gap_Airport heoe()
‘upply_tenand_gap_Airport drop(colunnss["CanceT led", "No Cars Available"), Srplace-True)
supply_denand_gap_Airport.heos()
Supply_senand gap Airport{"tSuccessful"] = 200"supply_denard gap Airport “Trip Carpeted” |/supply_denand gop Airport-TotalRequests
Supply_denand_gap_Airport( "trai led) = 280%supply_ demand gap Asroort["Fastea"|/supoly_cenand gop Airport TotaiResuests
Supply_cenand gap Airport deop(colunese[ Trip Conpieted","TolaiRequests™, Failed” inplace-TPve)
‘Supply_éerand_g3p_Airport neae()
Status successful Xrated
OF Early Moming 70841807 20,158108
ozMeming 82312500 7.187500
osAtemoon 7.206187 32:739819,
04 ary Evening 90:352304 69.647606
osEvening 21271077 ra.728028
hntps:iiolab research [Link]/1ORG_miveRSetovXFSn7GgXOpS86bs}GxtprntMode=true 311832791124, 10:56 AM solution_case_study_8138_LecS.ipynb - Colaboratory
# Lets first Look st the denand supply gap for Airport and create a bar chart for it
es = supply_comana_g3p_Airpors([ "Sra les,"xSuccessfel” plot (kindebar”, figrs7eq[ 25,8], stackedsIrue,coloresp="ReViGn", fontsize=32)
rer sot_facecolor("Tlantersy")
plt-eitie("Supply Denand Sap from Airport to City\n",fontstze.25,fontaeight="aole", loc-"Ieft")
pit-xdabel("\ntire Period" fortsize=22)
pit-setp([Link]. get najortictlabels(), fontsize=20,rotat
pltiylabel(“X Requests\n"fontsizes22)
it. setp([Link].get_najorticelabels(), fontsize=20)
ge = [Link](title= Trip status, title fontsizert5,loce'ypper center",
Sat, netent = puget wicth(), puget nesehs()
By = pasty
es sext(ieeh/2,
o.
{2 04}" forma (helaht)
horizontatalignnents" center",
0)
2), stadowerrve, ncoled, labelse[“#Failed",
verticalalipment™"bottor’ fontes2e-15,color="y")
[Link](“22 - supply demand Gap on Ainport to City. JoeR"