davidgasquez commited on
Commit
7784761
·
verified ·
1 Parent(s): 87453aa

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +3 -8
  2. datapackage.yaml +2 -2
  3. owid.py +49 -0
README.md CHANGED
@@ -1,14 +1,9 @@
1
-
2
  ---
3
  license: mit
4
  ---
5
- # owid_indicators
6
 
7
- Joined energy and CO2 data from Our World in Data.
8
 
9
- This dataset is produced and published automatically by [Datadex](https://github.com/davidgasquez/datadex),
10
- a fully open-source, serverless, and local-first Data Platform that improves how communities collaborate on Open Data.
11
 
12
- ## Dataset Details
13
- - **Number of rows:** 16202
14
- - **Number of columns:** 207
 
 
1
  ---
2
  license: mit
3
  ---
 
4
 
5
+ # Our World In Data Indicators
6
 
7
+ Joined energy and CO2 data from Our World in Data.
 
8
 
9
+ This dataset is produced and published automatically by [Datadex](https://github.com/davidgasquez/datadex), a fully open-source, serverless, and local-first Data Platform that improves how communities collaborate on Open Data.
 
 
datapackage.yaml CHANGED
@@ -1,4 +1,4 @@
1
  name: owid_indicators
2
  resources:
3
- - format: parquet
4
- path: data/owid_indicators.parquet
 
1
  name: owid_indicators
2
  resources:
3
+ - format: parquet
4
+ path: data/owid_indicators.parquet
owid.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import polars as pl
2
+
3
+ from datadex import materialize
4
+
5
+
6
+ def owid_energy_data() -> pl.DataFrame:
7
+ """
8
+ Raw Energy data from Our World in Data.
9
+ """
10
+ energy_owid_url = (
11
+ "https://raw.githubusercontent.com/owid/energy-data/master/owid-energy-data.csv"
12
+ )
13
+
14
+ return pl.read_csv(
15
+ energy_owid_url, try_parse_dates=True, infer_schema_length=None
16
+ ).shrink_to_fit()
17
+
18
+
19
+ def owid_co2_data() -> pl.DataFrame:
20
+ """
21
+ Raw CO2 data from Our World in Data.
22
+ """
23
+ co2_owid_url = (
24
+ "https://raw.githubusercontent.com/owid/co2-data/master/owid-co2-data.csv"
25
+ )
26
+
27
+ return pl.read_csv(
28
+ co2_owid_url, try_parse_dates=True, infer_schema_length=None
29
+ ).shrink_to_fit()
30
+
31
+
32
+ def owid_indicators() -> pl.DataFrame:
33
+ """
34
+ Joined energy and CO2 data from Our World in Data.
35
+ """
36
+
37
+ df: pl.DataFrame = owid_energy_data().join(
38
+ owid_co2_data(), on=["iso_code", "year"], how="inner", suffix="_co2"
39
+ )
40
+
41
+ return df.sort(["iso_code", "year"])
42
+
43
+
44
+ def main() -> None:
45
+ materialize(owid_indicators)
46
+
47
+
48
+ if __name__ == "__main__":
49
+ main()