gtfs_df 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/lib/gtfs_df/base_gtfs_table.rb +1 -1
- data/lib/gtfs_df/feed.rb +6 -4
- data/lib/gtfs_df/reader.rb +14 -3
- data/lib/gtfs_df/utils.rb +6 -6
- data/lib/gtfs_df/version.rb +1 -1
- metadata +3 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3258de8699df9b1e0eb934b3edab17a0381536dbdf7bde0275f375854392478d
|
|
4
|
+
data.tar.gz: c67a356c1fca9818b89a936dac816826f4a00b50b990d352d59d96d1231a4104
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 881cf6027f5e68eda3916153889ac96f27f992ac411564a5232ae6b409b2488d41b596bcc23a6a4492c0a9fc2fce471986dd5ce07ede354a87a4b21033e0d4c8
|
|
7
|
+
data.tar.gz: 6f68989b3220ba20c6fc185560f0fedda797d4f0e06735a3c366f1722ecf6ce9fa35698716c0f339852202ceda7b9f4c8ef13fcb95b3e185a83202755d84f00e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [0.11.0] - 2026-03-30
|
|
2
|
+
|
|
3
|
+
### ⚙️ Miscellaneous Tasks
|
|
4
|
+
|
|
5
|
+
- [**breaking**] Update ruby-polars dependency
|
|
6
|
+
## [0.10.2] - 2026-03-20
|
|
7
|
+
|
|
8
|
+
### 🐛 Bug Fixes
|
|
9
|
+
|
|
10
|
+
- Handle nested feeds
|
|
11
|
+
|
|
12
|
+
### ⚙️ Miscellaneous Tasks
|
|
13
|
+
|
|
14
|
+
- Raise clear message for multi-feed inputs
|
|
15
|
+
- Bump version to 0.10.2
|
|
1
16
|
## [0.10.1] - 2026-03-18
|
|
2
17
|
|
|
3
18
|
### 🐛 Bug Fixes
|
|
@@ -8,6 +23,7 @@
|
|
|
8
23
|
|
|
9
24
|
- Normalize platforms
|
|
10
25
|
- Ignore the examples folder on publishing
|
|
26
|
+
- Bump version to 0.10.1
|
|
11
27
|
## [0.10.0] - 2026-03-06
|
|
12
28
|
|
|
13
29
|
### 🚀 Features
|
|
@@ -22,7 +22,7 @@ module GtfsDf
|
|
|
22
22
|
dtypes = self.class::SCHEMA.slice(*df.columns)
|
|
23
23
|
df
|
|
24
24
|
.with_columns(dtypes.keys.map do |col|
|
|
25
|
-
stripped = Polars.col(col).str.
|
|
25
|
+
stripped = Polars.col(col).str.strip_chars
|
|
26
26
|
Polars.when(stripped.str.len_chars.gt(0))
|
|
27
27
|
.then(stripped)
|
|
28
28
|
.otherwise(Polars.lit(nil))
|
data/lib/gtfs_df/feed.rb
CHANGED
|
@@ -128,12 +128,12 @@ module GtfsDf
|
|
|
128
128
|
trip_ids = if trip_ids.empty?
|
|
129
129
|
new_filtered["trips"]["trip_id"]
|
|
130
130
|
else
|
|
131
|
-
trip_ids.filter(trip_ids.is_in(new_filtered["trips"]["trip_id"]))
|
|
131
|
+
trip_ids.filter(trip_ids.is_in(new_filtered["trips"]["trip_id"].implode))
|
|
132
132
|
end
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
if trip_ids
|
|
136
|
-
filtered = filter!("trips", {"trip_id" => trip_ids
|
|
136
|
+
filtered = filter!("trips", {"trip_id" => trip_ids}, filtered.dup)
|
|
137
137
|
end
|
|
138
138
|
end
|
|
139
139
|
|
|
@@ -330,7 +330,7 @@ module GtfsDf
|
|
|
330
330
|
|
|
331
331
|
# Get the week with max trips
|
|
332
332
|
# Sort by total_trips descending, then date ascending to pick the earliest date in case of a tie
|
|
333
|
-
sorted_weeks = weekly_agg.sort(["total_trips", "week_start"],
|
|
333
|
+
sorted_weeks = weekly_agg.sort(["total_trips", "week_start"], descending: [true, false])
|
|
334
334
|
best_week = sorted_weeks.head(1)
|
|
335
335
|
|
|
336
336
|
return nil if best_week.height == 0
|
|
@@ -346,7 +346,9 @@ module GtfsDf
|
|
|
346
346
|
df = filtered[file]
|
|
347
347
|
|
|
348
348
|
filters.each do |col, val|
|
|
349
|
-
df = if val.is_a?(Polars::Series)
|
|
349
|
+
df = if val.is_a?(Polars::Series)
|
|
350
|
+
df.filter(Polars.col(col).is_in(val.implode))
|
|
351
|
+
elsif val.is_a?(Array)
|
|
350
352
|
df.filter(Polars.col(col).is_in(val))
|
|
351
353
|
elsif val.respond_to?(:call)
|
|
352
354
|
df.filter(val.call(Polars.col(col)))
|
data/lib/gtfs_df/reader.rb
CHANGED
|
@@ -14,15 +14,26 @@ module GtfsDf
|
|
|
14
14
|
.map { |name| "#{name}.txt" }
|
|
15
15
|
.to_set
|
|
16
16
|
|
|
17
|
+
seen = {}
|
|
18
|
+
|
|
17
19
|
Dir.mktmpdir do |tmpdir|
|
|
18
20
|
Zip::File.open(zip_path) do |zip_file|
|
|
19
21
|
zip_file.each do |entry|
|
|
22
|
+
# Extract files in nested directories into the root of the tmpdir
|
|
23
|
+
file_name = File.basename(entry.name)
|
|
24
|
+
|
|
25
|
+
if seen[file_name]
|
|
26
|
+
raise GtfsDf::Error, "Found multiple instances of the same file: #{seen[file_name]} and #{entry.name}"
|
|
27
|
+
end
|
|
28
|
+
|
|
20
29
|
# We're skipping:
|
|
21
|
-
# - directories
|
|
22
30
|
# - unrelated files
|
|
23
31
|
# - empty feed files
|
|
24
|
-
next unless
|
|
25
|
-
|
|
32
|
+
next unless relevant_files.include?(file_name) && has_header?(entry)
|
|
33
|
+
|
|
34
|
+
seen[file_name] = entry.name
|
|
35
|
+
|
|
36
|
+
entry.extract(file_name, destination_directory: tmpdir)
|
|
26
37
|
end
|
|
27
38
|
end
|
|
28
39
|
|
data/lib/gtfs_df/utils.rb
CHANGED
|
@@ -17,9 +17,9 @@ module GtfsDf
|
|
|
17
17
|
def as_seconds_since_midnight(col_name)
|
|
18
18
|
parts = Polars.col(col_name).str.split(":")
|
|
19
19
|
|
|
20
|
-
hours = parts.list.get(0).cast(
|
|
21
|
-
minutes = parts.list.get(1).cast(
|
|
22
|
-
seconds = parts.list.get(2).cast(
|
|
20
|
+
hours = parts.list.get(0).cast(Polars::Int64)
|
|
21
|
+
minutes = parts.list.get(1).cast(Polars::Int64)
|
|
22
|
+
seconds = parts.list.get(2).cast(Polars::Int64)
|
|
23
23
|
|
|
24
24
|
(hours * SECONDS_IN_HOUR) +
|
|
25
25
|
(minutes * SECONDS_IN_MINUTE) +
|
|
@@ -42,9 +42,9 @@ module GtfsDf
|
|
|
42
42
|
|
|
43
43
|
Polars.format(
|
|
44
44
|
"{}:{}:{}",
|
|
45
|
-
hours.cast(
|
|
46
|
-
minutes.cast(
|
|
47
|
-
seconds.cast(
|
|
45
|
+
hours.cast(Polars::String).str.zfill(2),
|
|
46
|
+
minutes.cast(Polars::String).str.zfill(2),
|
|
47
|
+
seconds.cast(Polars::String).str.zfill(2)
|
|
48
48
|
)
|
|
49
49
|
end
|
|
50
50
|
|
data/lib/gtfs_df/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gtfs_df
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Mejorado
|
|
@@ -30,20 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0.
|
|
34
|
-
- - "<"
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
36
|
-
version: '0.24'
|
|
33
|
+
version: '0.25'
|
|
37
34
|
type: :runtime
|
|
38
35
|
prerelease: false
|
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
37
|
requirements:
|
|
41
38
|
- - "~>"
|
|
42
39
|
- !ruby/object:Gem::Version
|
|
43
|
-
version: '0.
|
|
44
|
-
- - "<"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '0.24'
|
|
40
|
+
version: '0.25'
|
|
47
41
|
- !ruby/object:Gem::Dependency
|
|
48
42
|
name: rubyzip
|
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|