In [1]:
import pandas as pd

In [2]:
# Read the file
raw_data = pd.ExcelFile('London_Sundays_2000.xlsx')
data = raw_data.parse('Sheet1')

In [3]:
data.head()


Out[3]:
Accident_Index Location_Easting_OSGR Location_Northing_OSGR Longitude Latitude Police_Force Accident_Severity Number_of_Vehicles Number_of_Casualties Date ... Pedestrian_Crossing-Human_Control Pedestrian_Crossing-Physical_Facilities Light_Conditions Weather_Conditions Road_Surface_Conditions Special_Conditions_at_Site Carriageway_Hazards Urban_or_Rural_Area Did_Police_Officer_Attend_Scene_of_Accident LSOA_of_Accident_Location
5118301 20000141T3256 534060 200000 -0.062236 51.682716 1 3 8 5 29/10/2000 ... 0 0 4 5 5 0 0 2 1 E01001412
5118310 20000141T3324 529670 200520 -0.125507 51.688419 1 3 2 1 17/12/2000 ... 0 0 4 1 2 0 0 2 1 E01001412
5118318 20000142G0092 556810 192270 0.263122 51.607380 1 3 3 1 06/02/2000 ... 0 0 4 1 2 0 0 2 1 E01002296
5118326 20000142G0220 557210 191300 0.268459 51.598554 1 3 2 4 02/04/2000 ... 0 0 1 1 1 0 0 2 1 E01002296
5118331 20000142G0373 558450 188310 0.284999 51.571343 1 3 2 1 14/05/2000 ... 0 0 1 1 1 0 0 2 1 E01002252

5 rows × 32 columns


In [10]:
# Raining + high winds = 5
# darkness + unlit roads = 5

# When it was raining + dark

dark_and_stormy = data[(data.Light_Conditions == 5) & (data.Weather_Conditions == 2) ]
len(dark_and_stormy)


Out[10]:
1

In [11]:
dark_and_stormy


Out[11]:
Accident_Index Location_Easting_OSGR Location_Northing_OSGR Longitude Latitude Police_Force Accident_Severity Number_of_Vehicles Number_of_Casualties Date ... Pedestrian_Crossing-Human_Control Pedestrian_Crossing-Physical_Facilities Light_Conditions Weather_Conditions Road_Surface_Conditions Special_Conditions_at_Site Carriageway_Hazards Urban_or_Rural_Area Did_Police_Officer_Attend_Scene_of_Accident LSOA_of_Accident_Location
5154805 200001ZD00633 532170 165110 -0.10264 51.36962 1 3 1 1 28/05/2000 ... 0 0 5 2 2 0 0 1 1 E01001042

1 rows × 32 columns


In [14]:
# snow
data[(data.Road_Surface_Conditions == 3)]


Out[14]:
Accident_Index Location_Easting_OSGR Location_Northing_OSGR Longitude Latitude Police_Force Accident_Severity Number_of_Vehicles Number_of_Casualties Date ... Pedestrian_Crossing-Human_Control Pedestrian_Crossing-Physical_Facilities Light_Conditions Weather_Conditions Road_Surface_Conditions Special_Conditions_at_Site Carriageway_Hazards Urban_or_Rural_Area Did_Police_Officer_Attend_Scene_of_Accident LSOA_of_Accident_Location
5138674 200001PY01070 544130 165840 0.069358 51.373273 1 3 1 1 05/11/2000 ... 0 0 4 2 3 0 0 1 1 E01000753

1 rows × 32 columns


In [17]:
# icy and frosty

data_frosty = data[(data.Road_Surface_Conditions == 4)]
data_frosty


Out[17]:
Accident_Index Location_Easting_OSGR Location_Northing_OSGR Longitude Latitude Police_Force Accident_Severity Number_of_Vehicles Number_of_Casualties Date ... Pedestrian_Crossing-Human_Control Pedestrian_Crossing-Physical_Facilities Light_Conditions Weather_Conditions Road_Surface_Conditions Special_Conditions_at_Site Carriageway_Hazards Urban_or_Rural_Area Did_Police_Officer_Attend_Scene_of_Accident LSOA_of_Accident_Location
5130517 200001KG00240 546940 182930 0.116793 51.526117 1 3 2 1 09/04/2000 ... 0 0 4 1 4 0 0 1 1 E01000094
5136556 200001PL00032 538190 171850 -0.013588 51.428757 1 3 2 1 16/01/2000 ... 0 0 4 1 4 0 0 1 1 E01003352
5140110 200001QK00006 523730 182970 -0.217584 51.532035 1 2 2 2 09/01/2000 ... 0 5 1 1 4 0 0 1 1 E01000586
5142616 200001RY09024 548990 175130 0.143033 51.455494 1 3 2 1 17/12/2000 ... 0 0 4 1 4 0 0 1 2 E01000362
5142674 200001SA00059 518950 200420 -0.280547 51.689892 1 3 1 1 13/02/2000 ... 0 0 6 1 4 0 0 2 1 E01023582
5146308 200001TX01414 512480 178040 -0.381274 51.490076 1 3 2 1 17/12/2000 ... 0 0 4 8 4 0 0 1 1 E01002631
5149135 200001XH00041 507010 184580 -0.458047 51.549920 1 2 1 2 16/01/2000 ... 0 0 4 1 4 0 0 1 1 E01002513
5149137 200001XH00043 511080 184420 -0.399422 51.547696 1 3 1 1 16/01/2000 ... 0 0 1 1 4 0 0 1 1 E01002499
5151532 200001YE00012 533270 192330 -0.076577 51.613979 1 2 1 1 09/01/2000 ... 0 1 4 1 4 0 0 1 1 E01001562

9 rows × 32 columns


In [18]:
data_frosty.to_csv("London_frosty.csv")

In [ ]: