Skip to content

Commit c060cc1

Browse files
authored
Merge pull request #1419 from cal-itp/annual_ridership
NTD ID to RTPA crosswalk
2 parents cedce52 + dff4465 commit c060cc1

File tree

7 files changed

+8657
-2306
lines changed

7 files changed

+8657
-2306
lines changed

ntd/annual_ridership_report/README.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,17 @@
33

44
Provide CalSTA with NTD Annual Ridership by each regional transportation planning authority (RTPA)
55

6-
This reoport shows general ridership trends by agency, mode and type of service.
6+
Per the [SB125 Final Guildelines](https://calsta.ca.gov/-/media/calsta-media/documents/sb125-final-guidelines-a11y.pdf)
7+
>Caltrans will provide all RTPAs with a summary report each month that meets the requirements of this statutory provision... For RTPAs with transit operators who do not report monthly data to the NTD, Caltrans will include the most recent annual ridership numbers provided to the NTD. RTPAs may publish
78
8-
## Dataset
9-
1. [NTD Annual Service data](https://www.transit.dot.gov/ntd/data-product/2022-annual-database-service)
10-
2. [RTPA list](https://gis.data.ca.gov/datasets/CAEnergy::regional-transportation-planning-agencies/explore?appid=cf412a17daaa47bca93c6d6b7e77aff0&edit=true)
11-
3. Download our processed data here
129

13-
---
14-
15-
# Annual NTD Ridership by RTPA
16-
17-
In response to... and the accompany the Monthly NTD Ridership Report, Caltrans is providing CalSTA with NTD Annual ridership by RTPA.
18-
19-
This report shows general ridership trends by Annual NTD Reporter by mode, and type of service for California RTPAs from 2018 to present. Unlinked passenger trips are reported, as well as the change from the prior year. For example, July 2023's change would be the change in July 2023's reported values against July 2022's reported values.
10+
This report shows general ridership trends by Annual NTD Reporter for California RTPAs. Unlinked passenger trips are reported, as well as the change from the prior year. For example, July 2023's change would be the change in July 2023's reported values against July 2022's reported values.
2011

2112
## Definitions
2213
- **FTA**: Federal Transit Admisistration.
23-
- **MODE**: A system for carrying transit passengers described by specific right-of-way (ROW), technology and operational features. Examples: Bus, Cable Car, Light Rail.
24-
- **Monthly NTD Reporter**: Full Reporters that submit Monthly Ridership (MR) and monthly Safety and Security reports to NTD.
14+
- **Annual NTD Reporter**: Transit agencies that are requried to report yearly to the NTD, includes rural, urban and reduced reporters.
2515
- **NTD**: National Transit Database. A reporting system that collects public transportation financial and operating information.
2616
- **RTPA**: Regional Transportation Planning Authority.
27-
- **TOS**: Type of Service. Describes how public transportation services are provided by the transit agency: directly operated (DO) or purchased transportation (PT) services.
2817
- **UZA**: Urbanized Areas. An urbanized area is an incorporated area with a population of 50,000 or more that is designated as such by the U.S. Department of Commerce, Bureau of the Census.
2918

3019

@@ -60,7 +49,7 @@ Per the [SB125 Final Guildelines](https://calsta.ca.gov/-/media/calsta-media/doc
6049
Hyperlinking this report on your RTPA's/Agency's webpage is a common method to meeting this requirement.
6150

6251
## Datasets / Data Sources
63-
- [NTD Complete Monthly Ridership Report](....)
52+
- [NTD Annual Service data](https://www.transit.dot.gov/ntd/data-product/2022-annual-database-service
6453
- [California RTPA list](https://gis.data.ca.gov/datasets/CAEnergy::regional-transportation-planning-agencies/explore?appid=cf412a17daaa47bca93c6d6b7e77aff0&edit=true)
6554
- [Fully Processed Data Download](https://console.cloud.google.com/storage/browser/calitp-publish-data-analysis)
6655

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# all functions used for annual ridership report
2+
3+
import pandas as pd
4+
5+
def get_percent_change(
6+
df: pd.DataFrame,
7+
) -> pd.DataFrame:
8+
"""
9+
Calculates % change of UPT from previous year
10+
"""
11+
df["pct_change_1yr"] = (
12+
(df["upt"] - df["previous_y_upt"])
13+
.divide(df["upt"])
14+
.round(4)
15+
)
16+
17+
return df
18+
19+
def add_change_columns(
20+
df: pd.DataFrame) -> pd.DataFrame:
21+
"""
22+
Calculates (value) change of UPT from previous year.
23+
Sorts the df by ntd id. then adds new columns:
24+
1. previous year/month UPT
25+
"""
26+
27+
sort_cols2 = ["ntd_id",
28+
"report_year",
29+
#"mode",
30+
#"tos",
31+
#"period_month",
32+
#"period_year"
33+
] # got the order correct with ["period_month", "period_year"]! sorted years with grouped months
34+
group_cols2 = ["ntd_id",
35+
#"mode",
36+
#"tos"
37+
]
38+
39+
#df[["period_year","period_month"]] = df[["period_year","period_month"]].astype(int)
40+
41+
df = df.assign(
42+
previous_y_upt = (df.sort_values(sort_cols2)
43+
.groupby(group_cols2)["upt"]
44+
.apply(lambda x: x.shift(1))
45+
)
46+
)
47+
48+
df["change_1yr"] = (df["upt"] - df["previous_y_upt"])
49+
50+
df = get_percent_change(df)
51+
52+
return df
53+
54+
55+
56+
57+

0 commit comments

Comments
 (0)