Uber Ride Data Analysis
Goal
Given Uber ride/trip records:
- Find peak hours and weekdays
- Visualize trip volume over time
- Identify hotspots (if location data exists)
Analysis pipeline
flowchart LR A["Raw trips
(timestamps)"] --> B["Extract
(hour, weekday)"] B --> C["Count
(trips per hour/day)"] C --> D["Visualize
(demand curve)"] D --> E["Conclude
(peak hours/days)"]
Step 1: Load and parse timestamps
Load trips
import pandas as pd
df = pd.read_csv("data/uber.csv")
df["timestamp"] = pd.to_datetime(df["timestamp"], errors="coerce")
print(df.head())Load trips
import pandas as pd
df = pd.read_csv("data/uber.csv")
df["timestamp"] = pd.to_datetime(df["timestamp"], errors="coerce")
print(df.head())Step 2: Extract time features
Time features
df["hour"] = df["timestamp"].dt.hour
df["weekday"] = df["timestamp"].dt.day_name()Time features
df["hour"] = df["timestamp"].dt.hour
df["weekday"] = df["timestamp"].dt.day_name()Step 3: Plot trips by hour
Trips by hour
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(figsize=(8, 4))
sns.countplot(data=df, x="hour")
plt.title("Trips by hour")
plt.tight_layout()
plt.show()Trips by hour
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(figsize=(8, 4))
sns.countplot(data=df, x="hour")
plt.title("Trips by hour")
plt.tight_layout()
plt.show()Step 4: Trend over dates
Trips by day
import matplotlib.pyplot as plt
daily = df.dropna(subset=["timestamp"]).groupby(df["timestamp"].dt.date).size()
plt.figure(figsize=(10, 4))
plt.plot(daily.index, daily.values)
plt.title("Trips over time")
plt.xticks(rotation=20)
plt.tight_layout()
plt.show()Trips by day
import matplotlib.pyplot as plt
daily = df.dropna(subset=["timestamp"]).groupby(df["timestamp"].dt.date).size()
plt.figure(figsize=(10, 4))
plt.plot(daily.index, daily.values)
plt.title("Trips over time")
plt.xticks(rotation=20)
plt.tight_layout()
plt.show()Visualize it
Deliverable
- Peak hours
- Peak weekdays
- Trend changes (seasonality/events)
🧪 Try It Yourself
Exercise 1 – Extract the hour from a timestamp
Exercise 2 – Count trips per hour
Exercise 3 – Weekday name from a date
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
