Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions positron-bike-share/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.venv/
__pycache__/
.ipynb_checkpoints/
2,885 changes: 2,885 additions & 0 deletions positron-bike-share/data/bike_share_trips.csv

Large diffs are not rendered by default.

1,172 changes: 1,172 additions & 0 deletions positron-bike-share/notebooks/explore_trips.ipynb

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions positron-bike-share/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[project]
name = "positron-bike-share"
version = "0.1.0"
description = "Starter materials for a Positron hands-on Python tutorial"
requires-python = ">=3.14"
dependencies = [
"matplotlib>=3.9",
"nbformat==5.11.1",
"pandas>=2.2",
"plotly==7.0.0",
]

[tool.uv]
package = false
31 changes: 31 additions & 0 deletions positron-bike-share/src/analyze_trips.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# %%
from pathlib import Path

import matplotlib.pyplot as plt
import pandas as pd

PROJECT_ROOT = Path.cwd()
DATA_PATH = PROJECT_ROOT / "data" / "bike_share_trips.csv"

trips = pd.read_csv(DATA_PATH, parse_dates=["started_at", "ended_at"])

# %%
trips_by_hour = (
trips.assign(hour=trips["started_at"].dt.hour)
.groupby("hour", as_index=False)
.size()
.rename(columns={"size": "trip_count"})
)

ax = trips_by_hour.plot(
x="hour",
y="trip_count",
kind="line",
marker="o",
legend=False,
title="Bike Share Trips by Hour",
)
ax.set(xlabel="Hour of Day", ylabel="Trip Count")
ax.set_xticks(range(24))
plt.tight_layout()
plt.show()
Loading