Skip to content

Instantly share code, notes, and snippets.

@electron0zero
Created June 12, 2025 13:03
Show Gist options
  • Save electron0zero/7b2fd40a7e86232ff2ddd94e71791f31 to your computer and use it in GitHub Desktop.
Save electron0zero/7b2fd40a7e86232ff2ddd94e71791f31 to your computer and use it in GitHub Desktop.
Build Maps from the Uber Rides Data

Getting the data

Go to Uber and request a data download from https://help.uber.com/riders/article/request-a-copy-of-your-personal-data?nodeId=2c86900d-8408-4bac-b92a-956d793acd11

Here is what's in your data: https://help.uber.com/riders/article/whats-in-your-data-download?nodeId=3d476006-87a4-4404-ac1e-216825414e05

if these links don't work, data request is usually in Data and privacy section in your Uber app.

once you place a request, uber will email you a link to download the data.

download that zip file, unzip it, and open the Rider folder, and look for a file called trips_data-0.csv or something simialr.

take that csv file, make sure it's a valid CSV (sometimes address will have a " or , in them it will throw off the CSV file.

open the file in google sheets or other software and quote or the remove the bad string or quote them.

once data is fixed, make a copy of csv with name uber_trips.csv and move it to the same folder as code.

here is what the uber_trips.csv will look like (this is dummy data, not real data)

city	product_type	status	request_time	begin_trip_time	begintrip_lat	begintrip_lng	begintrip_address	dropoff_time	dropoff_lat	dropoff_lng	dropoff_address	distance	fare_currency	fare_amount											
Bangalore	uberPLUS	completed	2025-06-10T16:10:50.000Z	2025-06-10T16:22:27.000Z	21.960937	88.64797	HAL 2nd Stage, Kodihalli, Bengaluru, Karnataka 560008, India	2025-06-10T16:40:58.000Z	21.983022	88.673904	Kaggadasapura, Bengaluru, Karnataka 560093, India	4.32	Indian Rupee	232.47											
Bangalore	Uber Go Priority	completed	2025-06-04T17:32:30.000Z	2025-06-04T17:39:23.000Z	88.042858	77.60984	Service Road, Bengaluru, KA 560045	2025-06-04T18:15:09.000Z	21.983134	88.67392	Kaggadasapura, Bengaluru, Karnataka 560093, India	10.36	Indian Rupee	420.21											
Bangalore	Store Pickup	completed	2025-05-31T08:23:28.000Z	2025-05-31T08:40:56.000Z	32.9857	88.70828	Doddanakundi Industrial Area 2, Industrial Area, Whitefield, Bengaluru, Karnataka 560048, India	2025-05-31T09:07:01.000Z	21.950188	88.69934	Marathahalli, Bengaluru, Karnataka 560037, India	3.27	Indian Rupee	135.19											
Bangalore	uberGO	completed	2025-05-29T21:02:22.000Z	2025-05-29T21:06:21.000Z	21.973369	88.64077	Indiranagar, Bengaluru, Karnataka 560038, India	2025-05-29T21:18:20.000Z	12.9831085	77.673935	Kaggadasapura, Bengaluru, Karnataka 560093, India	3.74	Indian Rupee	183.41

Setup

  • pip install virtualenv
  • python3 -m venv uberenv
  • source uberenv/bin/activate
  • pip install pandas folium

Running

  • Put you uber rides data into a file called uber_trips.csv in the same folder as the scripts, this data is from the uber data download.
  • python plot_uber_trips_folium.py -> this will create an html file called uber_trips_map.html, just open it in chrome and play around with it.
  • python plot_uber_trips_folium_dots.py -> same as the last but will create a file called uber_trips_map_dots.html where trips are not connected by lines, better if you have a lots of trips and lines are too noisy.

You can play around with the data, click on the ride start and end dots, and it will show you address as well so that's neat.

PS: I used chatgpt to write most of these scripts, so it's not my code.

import pandas as pd
import folium
# Load data
df = pd.read_csv("uber_trips.csv")
# Filter only completed trips
df = df[df['status'] == 'completed']
# Create map
m = folium.Map(location=[12.9716, 77.5946], zoom_start=12)
# Plot trips
for _, row in df.iterrows():
start = [row['begintrip_lat'], row['begintrip_lng']]
end = [row['dropoff_lat'], row['dropoff_lng']]
# Line
folium.PolyLine([start, end], color='blue', weight=2, opacity=0.6).add_to(m)
# Start
folium.CircleMarker(
location=start,
radius=4,
color='green',
fill=True,
fill_opacity=0.7,
popup=f"Start: {row['begintrip_address']}"
).add_to(m)
# End
folium.CircleMarker(
location=end,
radius=4,
color='red',
fill=True,
fill_opacity=0.7,
popup=f"End: {row['dropoff_address']}"
).add_to(m)
# Save HTML
m.save("uber_trips_map.html")
print("Saved interactive map to 'uber_trips_map.html'")
import pandas as pd
import folium
# Load data
df = pd.read_csv("uber_trips.csv")
# Filter only completed trips
df = df[df['status'] == 'completed']
# Create map
m = folium.Map(location=[12.9716, 77.5946], zoom_start=12)
# Plot only start and end dots
for _, row in df.iterrows():
start = [row['begintrip_lat'], row['begintrip_lng']]
end = [row['dropoff_lat'], row['dropoff_lng']]
folium.CircleMarker(
location=start,
radius=4,
color='green',
fill=True,
fill_opacity=0.7,
popup=f"Start: {row['begintrip_address']}"
).add_to(m)
folium.CircleMarker(
location=end,
radius=4,
color='red',
fill=True,
fill_opacity=0.7,
popup=f"End: {row['dropoff_address']}"
).add_to(m)
# Save to file
m.save("uber_trips_map_dots.html")
print("Saved interactive map with only dots to 'uber_trips_map_dots.html'")

Comments are disabled for this gist.