By Susan Li
March 13 2017
Don’t want to be nailed? The City of Toronto publishes their parking tickets data every year. Below is one year parking tickets data to show you when and where most tickets are issued.
I will be using R and some of its extended libraries for this project.
## [1] 2254761 11
## 'data.frame': 2254761 obs. of 11 variables:
## $ tag_number_masked : chr "***03850" "***03851" "***98221" "***85499" ...
## $ date_of_infraction : int 20160101 20160101 20160101 20160101 20160101 20160101 20160101 20160101 20160101 20160101 ...
## $ infraction_code : int 29 29 29 29 406 3 29 29 406 29 ...
## $ infraction_description: chr "PARK PROHIBITED TIME NO PERMIT" "PARK PROHIBITED TIME NO PERMIT" "PARK PROHIBITED TIME NO PERMIT" "PARK PROHIBITED TIME NO PERMIT" ...
## $ set_fine_amount : int 30 30 30 30 40 30 30 30 40 30 ...
## $ time_of_infraction : int 0 1 2 2 2 3 3 4 4 5 ...
## $ location1 : chr "NR" "NR" "NR" "NR" ...
## $ location2 : chr "49 GLOUCESTER ST" "45 GLOUCESTER ST" "274 GEORGE ST" "270 GEORGE ST" ...
## $ location3 : chr "" "" "" "" ...
## $ location4 : chr "" "" "" "" ...
## $ province : chr "ON" "ON" "ON" "ON" ...
## Min. 1st Qu. Median Mean 3rd Qu.
## "2016-01-01" "2016-04-02" "2016-06-25" "2016-06-28" "2016-09-26"
## Max.
## "2016-12-31"
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0 30.0 30.0 48.6 50.0 450.0
The dataset can be accessed through City of Toronto Open Data Portal. It contains 2256761 parking tickets, from January 1 2016 to December 31 2016, the amount from 0 to $450. I will omit missing values in the data, that means 1331 rows are omitted. Also I will need to do some cleaning such as change the date and time format to the appropriate format. I also added a new column - day of week.
The number of parking tickets distributed almost evenly throughout the year. It seems slowing down towards the end of the year.
The time distribution appears bimodal with period peaking around 9am to 1pm and again after midnight. The safest time to park your car without being nailed is around 5 and 6am.
##
## 200 55 0 300 90 250 450 100 15
## 3 177 210 881 920 14655 16029 46356 119410
## 150 60 40 50 30
## 119615 211209 286409 337904 1099652
The most common amount is $30, then $50, then $40. I believe the “0” value means the parking tickets were cancelled.
So which dates have the most number of infractions? and which dates have the least number of infractions?
## # A tibble: 5 × 3
## date_of_infraction total_day n
## <date> <int> <int>
## 1 2016-04-01 452325 8977
## 2 2016-09-01 439350 8712
## 3 2016-11-01 420110 8541
## 4 2016-03-30 378740 8060
## 5 2016-06-01 403505 8051
## # A tibble: 5 × 3
## date_of_infraction total_day n
## <date> <int> <int>
## 1 2016-12-17 121890 2354
## 2 2016-10-10 116485 2303
## 3 2016-01-01 87380 1635
## 4 2016-12-26 59055 1031
## 5 2016-12-25 32405 725
April 1st has the most number of infractions, and December 25 has the least number of parking tickets issued. I wonder why.
Apparently, less infractions happened in the weekend than during the weekdays.
Now let’s look at what the infractions are. Because there are more than 200 different infractions, it makes sense to only look at the top 10.
## Source: local data frame [10 x 4]
## Groups: infraction_description [10]
##
## infraction_description infraction_code total n
## <chr> <int> <int> <int>
## 1 PARK-SIGNED HWY-PROHIBIT DY/TM 5 19187710 401542
## 2 PARK ON PRIVATE PROPERTY 3 10999860 366662
## 3 PARK PROHIBITED TIME NO PERMIT 29 10173720 339124
## 4 PARK FAIL TO DISPLAY RECEIPT 210 6399690 213323
## 5 PARK MACHINE-REQD FEE NOT PAID 207 3945120 131504
## 6 PARK - LONGER THAN 3 HOURS 2 1747395 116494
## 7 STOP-SIGNED HWY-PROHIBIT TM/DY 9 6625440 110424
## 8 STAND VEH.-PROHIBIT TIME/DAY 8 4583580 76393
## 9 STOP-SIGNED HIGHWAY-RUSH HOUR 403 11136300 74242
## 10 PARK-VEH. W/O VALID ONT PLATE 406 2730480 68262
Now, what are the top 10 locations that have the most infractions?
Here it is! Be aware when you are around thoes areas.
How about the trend? Is there any infraction type increase or decrease over time?
This is not a good looking graph. Most of the top infractions have been steady over time. only “PARK FAIL TO DISPLAY RECEIPT” had dropped since fall, and “PARK MACHINE-REQD FEE NOT PAID” had an increase since October. Does it have anything to do with the season? or weather? Or simply more park machines broken toward the end of the year?
This is a much better looking graph. the highest counts are around noon time during the weekday, this trend changed during the weekend.
Now let me drill down to the top 10 infractions.
## [1] "PARK-SIGNED HWY-PROHIBIT DY/TM" "PARK ON PRIVATE PROPERTY"
## [3] "PARK PROHIBITED TIME NO PERMIT" "PARK FAIL TO DISPLAY RECEIPT"
## [5] "PARK MACHINE-REQD FEE NOT PAID" "PARK - LONGER THAN 3 HOURS "
## [7] "STOP-SIGNED HWY-PROHIBIT TM/DY" "STAND VEH.-PROHIBIT TIME/DAY"
## [9] "STOP-SIGNED HIGHWAY-RUSH HOUR" "PARK-VEH. W/O VALID ONT PLATE"
I found two sharp curved infractions interesting, one is “STOP-SIGNED HIGHWAY RUSH-HOUR”, there are two peak infraction hours around 8am and 4pm during the weekdays, the weekend is very quiet. It makes sense as it labels as “RUSH-HOUR”. Another is ‘PARK-LONGER THAN 3 HOURS’, this is the only infractions happened more during the early hours around 4am, this applies to weekends as well as weekdays.
It seems to me that residents live in an appartment building without a garage will be ticketed for overnight parking on their street if their street has no on-street permits. That’s why most of the infractions happened in the early hours of the day.
The above analysis doesn’t represent all the problems and areas since not every illegally parked car will be reported. It does give a general idea and might start a conversation on how and where the City of Toronto should intervene.