-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'lsoa_bornames' of https://github.com/palpatel0/project-…
…daylight-robbery into pr/28
- Loading branch information
Showing
15 changed files
with
346 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# Aviation Security (SO18) Borough | ||
|
||
The most standout borough in the Met crime stats dataset is the one named "Aviation Security (SO18)". Perhaps unsurprisingly, you won't find this borough in [lists of London Boroughs](https://en.wikipedia.org/wiki/List_of_London_boroughs). | ||
|
||
```{python} | ||
import math | ||
import numpy as np | ||
import pandas as pd | ||
import matplotlib.pyplot as plt | ||
from projtools.data import Data | ||
plt.style.use('../styles/rose-pine-dawn.mplstyle') | ||
data = Data() | ||
``` | ||
|
||
```{python} | ||
(data.ward | ||
.loc[:, :, :, :, "Aviation Security (SO18)"] | ||
.index | ||
.get_level_values("ward_code") | ||
.unique()) | ||
``` | ||
|
||
There is only one ward associated with the Aviation Security (SO18) borough. Searching the rest of the data for the `ward_code` reveals that this ward is present in both Avaition Security (SO18) and Hillingdon (which is actually a London Borough)... | ||
|
||
```{python} | ||
(data.ward | ||
.loc[:, "E05013570", :] | ||
.index | ||
.get_level_values("borough") | ||
.unique()) | ||
``` | ||
|
||
A quick DuckDuckGo search will inform you that this borough represents a [specialist operations unit](https://en.wikipedia.org/wiki/Aviation_Security_Operational_Command_Unit) within the Met. The unit is responsible for the policing of Heathrow Airport and London City Airport which raised the question; why is there no ward associated with SO18 in the area of London City Airport? | ||
|
||
London City Airport is located in the borough of Newham... | ||
|
||
```{python} | ||
(data.ward | ||
.loc[:, :, :, :, "Newham"] | ||
.index | ||
.get_level_values("ward_name") | ||
.unique()) | ||
``` | ||
|
||
Looking on Newham's website we can see the the airport sits in the Royal Albert ward: | ||
|
||
 | ||
|
||
Source: [Newham Borough](https://www.newham.gov.uk/council/review-polling-districts-polling-places-new-ward-arrangements/2) | ||
|
||
Presumably the SO18 borough in the Heathrow Villages ward has been made to separate the data for reporting purposes. For whatever reason the same principle has not been applied in the case of London City Airport. | ||
|
||
Digging into the crime stats for the Heathrow Villages ward can give us an idea of when this change seems to have been made... | ||
|
||
```{python} | ||
(data.ward | ||
.loc["Heathrow Villages", :, :, "Other Theft", "Hillingdon"] | ||
.T | ||
.groupby(level="year") | ||
.sum() | ||
.plot(ylabel="number of crimes", title="other theft in Hillingdon")) | ||
``` | ||
|
||
There is a sharp decline in 2020 before a rise in 2022. A sharp decline in theft in 2020 can probably be explained by COVID-19 lockdowns, with the return to 'normal' activity causing a rise to near pre-pandemic levels. At first glance the sharp decline in 2023 is puzzling, the dataset runs until the end of October so the number of crimes shouldn't be this low. By plotting the SO18 numbers we get an idea of what might have happened... | ||
|
||
```{python} | ||
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(12,4), sharey=True) | ||
fig.tight_layout() | ||
(data.ward | ||
.loc["Heathrow Villages", :, :, "Other Theft"] | ||
.T | ||
.groupby(level="year") | ||
.sum() | ||
.plot(ax=axes[0], ylabel="number of crimes", title="other theft offences")) | ||
plot = (data.ward | ||
.loc["Heathrow Villages", :, :, "Other Theft"] | ||
.T | ||
.groupby(level="year") | ||
.sum() | ||
.sum(axis=1) | ||
.plot(ax=axes[1], title="other theft offences")) | ||
plot.legend(["E05013570 - Hillingdon & SO18"]) | ||
``` | ||
|
||
As you can see, the first other theft recorded in SO18 was in 2020, followed by a sharp rise in 2023. Adding the two sets of crimes together removes a large amount of the 2023 fall. It seems safe to assume that in 2023 the way the Met recorded data about crimes in this ward was changed leading to a shift in crimes from the Hillingdon row to the SO18 row. | ||
|
||
|
||
## Other Crimes | ||
|
||
Plotting all the crimes in which there is data recorded for both Hillingdon and SO18 we can see that the same 'shift' of recorded crimes from Hillingdon to SO18 in 2023 can be seen clearly across most offences. | ||
|
||
```{python} | ||
offences_both = (data.ward | ||
.loc["Heathrow Villages", :, :, :] | ||
.groupby(level="offence") | ||
.size()) == 2 | ||
offences_both = offences_both.keys()[offences_both] | ||
offences = (data.ward | ||
.loc["Heathrow Villages", :, :, :] | ||
.index | ||
.get_level_values("offence") | ||
.unique()) | ||
offences = offences[offences.isin(offences_both)] | ||
rows = math.ceil(len(offences) / 3) | ||
fig, axes = plt.subplots(nrows=rows, ncols=3, figsize=(20,40)) | ||
fig.tight_layout() | ||
fig.subplots_adjust(top=1.8) | ||
for index, value in enumerate(offences): | ||
y = index % 3 | ||
x = index // 3 | ||
plot_data = data.ward.xs(("Heathrow Villages", slice(None), slice(None), value), drop_level=False) | ||
plot = (plot_data.T | ||
.groupby(level="year") | ||
.sum() | ||
.plot(ax=axes[x,y], title=value, ylabel="number of crimes")) | ||
plot.legend(plot_data.index.get_level_values("borough")) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.