-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: pargent Signed-off-by: yihong0618 <zouzou0208@gmail.com> * fix: add requirements duckdb Signed-off-by: yihong0618 <zouzou0208@gmail.com> --------- Signed-off-by: yihong0618 <zouzou0208@gmail.com>
- Loading branch information
1 parent
46473b6
commit 058a222
Showing
3 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,4 @@ garmin-fit-sdk | |
haversine==2.8.0 | ||
garth | ||
pycryptodome | ||
duckdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import duckdb | ||
|
||
with duckdb.connect() as conn: | ||
conn.install_extension("sqlite") | ||
conn.load_extension("sqlite") | ||
conn.sql("ATTACH 'run_page/data.db' (TYPE SQLITE);USE data;") | ||
conn.sql( | ||
"COPY (SELECT * FROM activities) TO 'run_page/data.parquet' (FORMAT PARQUET);" | ||
) | ||
|
||
""" | ||
examples: | ||
duckdb.sql("select regexp_extract(location_country, '[\u4e00-\u9fa5]{2,}(εΈ|θͺζ²»ε·|ηΉε«θ‘ζΏεΊ)') as run_location, concat(try_cast(sum(distance/1000) as integer)::varchar,' km') as run_distance from read_parquet('https://github.com/yihong0618/run/raw/refs/heads/master/run_page/data.parquet') where run_location is not NULL group by run_location order by sum(distance) desc;").show(max_rows=50) | ||
ββββββββββββββββ¬βββββββββββββββ | ||
β run_location β run_distance β | ||
β varchar β varchar β | ||
ββββββββββββββββΌβββββββββββββββ€ | ||
β 倧θΏεΈ β 9328 km β | ||
β ζ²ι³εΈ β 2030 km β | ||
β εδΊ¬εΈ β 61 km β | ||
β ιΏζ²εΈ β 24 km β | ||
β ζ¬ε·εΈ β 21 km β | ||
β ηι¦εΈ β 21 km β | ||
β ηε°εΈ β 21 km β | ||
β δΈζ΅·εΈ β 12 km β | ||
β εδΉε·εΈ β 7 km β | ||
β δΈΉδΈεΈ β 5 km β | ||
β η¦ζΏεΊεΈ β 4 km β | ||
β η«Ήη°εΈ β 3 km β | ||
β δΌδΈιεΈ β 2 km β | ||
β ιΏζ₯εΈ β 1 km β | ||
β ι¦ε·εΈ β 1 km β | ||
β β 0 km β | ||
ββββββββββββββββ΄βββββββββββββββ€ | ||
β 16 rows 2 columns β | ||
βββββββββββββββββββββββββββββββ | ||
duckdb.sql("select start_date_local, distance, name, location_country from read_parquet('https://github.com/yihong0618/run/raw/refs/heads/master/run_page/data.parquet') order by run_id desc limit 1;") | ||
duckdb.sql("select start_date_local[:4] as year, sum(distance/1000)::integer from read_parquet('https://github.com/yihong0618/run/raw/refs/heads/master/run_page/data.parquet') group by year order by year desc;").show(max_rows=50) | ||
βββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ | ||
β year β CAST(sum((distance / 1000)) AS INTEGER) β | ||
β varchar β int32 β | ||
βββββββββββΌββββββββββββββββββββββββββββββββββββββββββ€ | ||
β 2024 β 1605 β | ||
β 2023 β 696 β | ||
β 2022 β 758 β | ||
β 2021 β 1244 β | ||
β 2020 β 1284 β | ||
β 2019 β 1344 β | ||
β 2018 β 405 β | ||
β 2017 β 964 β | ||
β 2016 β 901 β | ||
β 2015 β 436 β | ||
β 2014 β 823 β | ||
β 2013 β 790 β | ||
β 2012 β 387 β | ||
βββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββ€ | ||
β 13 rows 2 columns β | ||
βββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
duckdb.sql("SELECT concat(try_cast(distance/1000 as integer)::varchar,' km') as distance_km,count(*) FROM read_parquet('https://github.com/yihong0618/run/raw/refs/heads/master/run_page/data.parquet') GROUP BY distance_km order by count(*) desc;").show(max_rows=50) | ||
βββββββββββββββ¬βββββββββββββββ | ||
β distance_km β count_star() β | ||
β varchar β int64 β | ||
βββββββββββββββΌβββββββββββββββ€ | ||
β 2 km β 706 β | ||
β 3 km β 639 β | ||
β 1 km β 493 β | ||
β 5 km β 391 β | ||
β 4 km β 337 β | ||
β 6 km β 164 β | ||
β 10 km β 84 β | ||
β 8 km β 55 β | ||
β 7 km β 54 β | ||
β 0 km β 29 β | ||
β 12 km β 25 β | ||
β 11 km β 17 β | ||
β 9 km β 17 β | ||
β 15 km β 15 β | ||
β 21 km β 8 β | ||
β 16 km β 7 β | ||
β 14 km β 6 β | ||
β 20 km β 6 β | ||
β 17 km β 4 β | ||
β 18 km β 3 β | ||
β 19 km β 2 β | ||
β 13 km β 2 β | ||
β 43 km β 2 β | ||
β 24 km β 1 β | ||
β 41 km β 1 β | ||
β 28 km β 1 β | ||
βββββββββββββββ΄βββββββββββββββ€ | ||
β 26 rows 2 columns β | ||
ββββββββββββββββββββββββββββββ | ||
""" |