Update NYC_Motor_Vehicle_Collisions_and_Weather_Dataset.py
Browse files
NYC_Motor_Vehicle_Collisions_and_Weather_Dataset.py
CHANGED
@@ -77,27 +77,26 @@ class NYCMotorVehicleCollisionsWeatherDataset(datasets.GeneratorBasedBuilder):
|
|
77 |
|
78 |
def _generate_examples(self, filepath):
|
79 |
with open(filepath, encoding="utf-8") as f:
|
80 |
-
for key, line in enumerate(f):
|
81 |
-
row = json.loads(line)
|
82 |
yield key, {
|
83 |
-
"crash_date": row.get("
|
84 |
-
"borough": row.get("
|
85 |
-
"zip_code": row.get("
|
86 |
-
"latitude": row.get("
|
87 |
-
"longitude": row.get("
|
88 |
-
"collision_id": row.get("
|
89 |
-
"crash_time_period": row.get("
|
90 |
-
"contributing_factor_vehicles": row.get("
|
91 |
-
"vehicle_types": row.get("
|
92 |
-
"number_of_injuries": row.get("
|
93 |
-
"number_of_deaths": row.get("
|
94 |
-
"street_name": row.get("
|
95 |
-
"street_type": row.get("
|
96 |
-
"weather_description": row.get("
|
97 |
-
"precipitation": row.get("
|
98 |
-
"precipitation_type": row.get("
|
99 |
-
"temp_max": row.get("
|
100 |
-
"temp_min": row.get("
|
101 |
}
|
102 |
|
103 |
-
|
|
|
77 |
|
78 |
def _generate_examples(self, filepath):
|
79 |
with open(filepath, encoding="utf-8") as f:
|
80 |
+
for key, line in enumerate(f):
|
81 |
+
row = json.loads(line)
|
82 |
yield key, {
|
83 |
+
"crash_date": row.get("CRASH DATE", ""),
|
84 |
+
"borough": row.get("BOROUGH", ""),
|
85 |
+
"zip_code": row.get("ZIP CODE", ""),
|
86 |
+
"latitude": row.get("LATITUDE", None),
|
87 |
+
"longitude": row.get("LONGITUDE", None),
|
88 |
+
"collision_id": row.get("COLLISION_ID", None),
|
89 |
+
"crash_time_period": row.get("CRASH TIME PERIOD", ""),
|
90 |
+
"contributing_factor_vehicles": row.get("CONTRIBUTING FACTOR VEHICLES", "").split(", "),
|
91 |
+
"vehicle_types": row.get("VEHICLE TYPES", "").split(", "),
|
92 |
+
"number_of_injuries": row.get("NUMBER OF INJURIES", None),
|
93 |
+
"number_of_deaths": row.get("NUMBER OF DEATHS", None),
|
94 |
+
"street_name": row.get("STREET NAME", ""),
|
95 |
+
"street_type": row.get("STREET TYPE", ""),
|
96 |
+
"weather_description": row.get("WEATHER DESCRIPTION", ""),
|
97 |
+
"precipitation": row.get("PRECIPITATION", None),
|
98 |
+
"precipitation_type": row.get("PRECIPITATION TYPE", ""),
|
99 |
+
"temp_max": row.get("TEMPMAX", None),
|
100 |
+
"temp_min": row.get("TEMPMIN", None),
|
101 |
}
|
102 |
|
|