Skip to content

Commit 672814e

Browse files
Add Namma Metro ridership dashboard and README
- Introduced a new Streamlit application in `main.py` to display Namma Metro ridership data from a JSONL file. - Added a README file with installation instructions for running the Streamlit app.
1 parent 2336fd5 commit 672814e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

apps/namma_metro/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# README
2+
3+
```bash
4+
pip install streamlit
5+
streamlit run apps/namma_metro/main.py
6+
```

apps/namma_metro/main.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import streamlit as st
2+
import json
3+
import pandas as pd
4+
from pathlib import Path
5+
6+
from traffic_data_bengaluru.utils import *
7+
8+
data_directory = get_data_directory()
9+
ridership_filepath = data_directory / "namma_metro" / "raw" / "ridership.jsonl"
10+
11+
st.title("🚇 Namma Metro")
12+
st.set_page_config(page_title="Namma Metro Ridership", layout="wide")
13+
14+
records = []
15+
with open(ridership_filepath, "r") as f:
16+
for line in f:
17+
item = json.loads(line)
18+
results = item.get("results", [])
19+
if results:
20+
records.append(results[0])
21+
22+
if not records:
23+
st.warning("No ridership data found.")
24+
else:
25+
df = pd.DataFrame(records).sort_values(by='RidershipDate', ascending=False)
26+
st.dataframe(df)

0 commit comments

Comments
 (0)