Skip to content

Uber Ride Data Analysis

Given Uber ride/trip records:

  • Find peak hours and weekdays
  • Visualize trip volume over time
  • Identify hotspots (if location data exists)
diagram Uber demand analysis pipeline mermaid
From raw trip timestamps to peak-hour demand patterns.
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())
Time features
df["hour"] = df["timestamp"].dt.hour
df["weekday"] = df["timestamp"].dt.day_name()
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 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()
sketch Trips by hour of day p5.js
Tall bars around commute hours reveal the demand peaks.
  • Peak hours
  • Peak weekdays
  • Trend changes (seasonality/events)

Exercise 1 – Extract the hour from a timestamp

Section titled “Exercise 1 – Extract the hour from a timestamp”

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading