Skip to content

Commit c2b01d4

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b9c06ea commit c2b01d4

File tree

5 files changed

+21
-59
lines changed

5 files changed

+21
-59
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
[![CI](https://github.com/carbonplan/notebooks/actions/workflows/main.yaml/badge.svg)](https://github.com/carbonplan/notebooks/actions/workflows/main.yaml)
1515
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
1616

17-
1817
This repository includes Jupyter notebooks and other utilities for sharing our analysis and research.
1918

2019
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/carbonplan/notebooks/master?urlpath=lab)

biochar/biochar.ipynb

+5-7
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,15 @@
4343
"source": [
4444
"%matplotlib inline\n",
4545
"\n",
46-
"import logging\n",
4746
"import matplotlib.pyplot as plt\n",
4847
"import numpy as np\n",
4948
"import pandas as pd\n",
5049
"import statsmodels.api as sm\n",
51-
"\n",
52-
"from carbonplan_styles.mpl import set_theme\n",
5350
"from carbonplan_styles.colors import colors\n",
51+
"from carbonplan_styles.mpl import set_theme\n",
5452
"\n",
55-
"set_theme(style='carbonplan_light')\n",
56-
"c = colors('carbonplan_light')"
53+
"set_theme(style=\"carbonplan_light\")\n",
54+
"c = colors(\"carbonplan_light\")"
5755
]
5856
},
5957
{
@@ -219,8 +217,8 @@
219217
"metadata": {},
220218
"outputs": [],
221219
"source": [
222-
"import pandas as pd\n",
223-
"import numpy as np"
220+
"import numpy as np\n",
221+
"import pandas as pd"
224222
]
225223
},
226224
{

offset-project-fire/buffer_pool_analysis.ipynb

+6-21
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,9 @@
3434
"metadata": {},
3535
"outputs": [],
3636
"source": [
37-
"import numpy as np\n",
3837
"import pandas as pd\n",
39-
"import intake\n",
40-
"\n",
41-
"from carbonplan_styles.mpl import set_theme\n",
4238
"from carbonplan_styles.colors import colors\n",
39+
"from carbonplan_styles.mpl import set_theme\n",
4340
"\n",
4441
"# set options\n",
4542
"set_theme(style=\"carbonplan_light\")\n",
@@ -100,11 +97,7 @@
10097
"metadata": {},
10198
"outputs": [],
10299
"source": [
103-
"df = df[\n",
104-
" ~df[\"Forest Buffer Account Contribution\"].apply(\n",
105-
" lambda x: isinstance(x, str)\n",
106-
" )\n",
107-
"]\n",
100+
"df = df[~df[\"Forest Buffer Account Contribution\"].apply(lambda x: isinstance(x, str))]\n",
108101
"df = df[df[\"ARB Offset Credits Issued\"] > 0]\n",
109102
"forest_df = df[df[\"Project Type\"] == \"Forest\"]\n",
110103
"\n",
@@ -254,15 +247,11 @@
254247
"perc_credits[\"state\"] = perc_credits.index.map(proj_state_map)\n",
255248
"perc_credits = perc_credits.rename(\n",
256249
" # clean up column title\n",
257-
" columns={\n",
258-
" \"ARB Offset Credits Issued\": \"Percent Forest ARB Offset Credits Issued\"\n",
259-
" }\n",
250+
" columns={\"ARB Offset Credits Issued\": \"Percent Forest ARB Offset Credits Issued\"}\n",
260251
")\n",
261252
"\n",
262253
"proj_loc = perc_credits.index.get_loc(proj_id)\n",
263-
"display(\n",
264-
" perc_credits[: proj_loc + 1]\n",
265-
") # +1 to include ACR260, otherwise off by one"
254+
"display(perc_credits[: proj_loc + 1]) # +1 to include ACR260, otherwise off by one"
266255
]
267256
},
268257
{
@@ -298,15 +287,11 @@
298287
"sorted_credits[\"state\"] = sorted_credits.index.map(proj_state_map)\n",
299288
"sorted_credits = sorted_credits.rename(\n",
300289
" # clean up column title\n",
301-
" columns={\n",
302-
" \"ARB Offset Credits Issued\": \"Percent Forest ARB Offset Credits Issued\"\n",
303-
" }\n",
290+
" columns={\"ARB Offset Credits Issued\": \"Percent Forest ARB Offset Credits Issued\"}\n",
304291
")\n",
305292
"\n",
306293
"proj_loc = sorted_credits.index.get_loc(proj_id)\n",
307-
"display(\n",
308-
" sorted_credits[: proj_loc + 1]\n",
309-
") # +1 to include ACR260, otherwise off by one"
294+
"display(sorted_credits[: proj_loc + 1]) # +1 to include ACR260, otherwise off by one"
310295
]
311296
},
312297
{

offset-project-fire/fire_analysis.ipynb

+3-11
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,11 @@
5656
"import copy\n",
5757
"import os\n",
5858
"\n",
59-
"from carbonplan_styles.colors import colors\n",
60-
"import fsspec\n",
6159
"import geopandas\n",
62-
"import hvplot.pandas\n",
6360
"import intake\n",
6461
"import pandas as pd\n",
6562
"import pyproj\n",
66-
"import shapely\n",
63+
"from carbonplan_styles.colors import colors\n",
6764
"from shapely.ops import cascaded_union\n",
6865
"\n",
6966
"# plot styles\n",
@@ -244,9 +241,7 @@
244241
"source": [
245242
"burned_poly = cascaded_union(full_res.geometry.values)\n",
246243
"burned_gdf = (\n",
247-
" geopandas.GeoDataFrame.from_dict(\n",
248-
" {\"row\": {\"geometry\": burned_poly}}, orient=\"index\"\n",
249-
" )\n",
244+
" geopandas.GeoDataFrame.from_dict({\"row\": {\"geometry\": burned_poly}}, orient=\"index\")\n",
250245
" .set_geometry(\"geometry\")\n",
251246
" .set_crs(working_crs)\n",
252247
")"
@@ -310,10 +305,7 @@
310305
"\n",
311306
"burned_project_area = burned_project.area.sum()\n",
312307
"print(\"Burned Project Area: %.2f m2\" % burned_project_area)\n",
313-
"print(\n",
314-
" \"Percent Project Burned: %.2f%%\"\n",
315-
" % (burned_project_area / project_area * 100)\n",
316-
")"
308+
"print(\"Percent Project Burned: %.2f%%\" % (burned_project_area / project_area * 100))"
317309
]
318310
},
319311
{

projects/projects.ipynb

+7-19
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@
1616
"metadata": {},
1717
"outputs": [],
1818
"source": [
19-
"import requests\n",
20-
"import pandas as pd\n",
2119
"import altair as alt\n",
22-
"\n",
20+
"import pandas as pd\n",
21+
"import requests\n",
2322
"from IPython.display import JSON\n",
2423
"\n",
25-
"\n",
2624
"alt.themes.enable(\"carbonplan_light\")"
2725
]
2826
},
@@ -55,9 +53,7 @@
5553
"outputs": [],
5654
"source": [
5755
"# or get the full schema for a specific object\n",
58-
"schema = requests.get(\n",
59-
" \"https://api.carbonplan.org/schema/ProjectCollection.json\"\n",
60-
").json()\n",
56+
"schema = requests.get(\"https://api.carbonplan.org/schema/ProjectCollection.json\").json()\n",
6157
"JSON(schema)"
6258
]
6359
},
@@ -77,9 +73,7 @@
7773
"metadata": {},
7874
"outputs": [],
7975
"source": [
80-
"project_collection = requests.get(\n",
81-
" \"https://api.carbonplan.org/projects.json\"\n",
82-
").json()\n",
76+
"project_collection = requests.get(\"https://api.carbonplan.org/projects.json\").json()\n",
8377
"JSON(project_collection, root=\"project_collection\")"
8478
]
8579
},
@@ -97,9 +91,7 @@
9791
"metadata": {},
9892
"outputs": [],
9993
"source": [
100-
"one_project = requests.get(\n",
101-
" \"https://api.carbonplan.org/projects.json?id=STRP01\"\n",
102-
").json()\n",
94+
"one_project = requests.get(\"https://api.carbonplan.org/projects.json?id=STRP01\").json()\n",
10395
"JSON(one_project)"
10496
]
10597
},
@@ -117,9 +109,7 @@
117109
"metadata": {},
118110
"outputs": [],
119111
"source": [
120-
"projects = pd.read_csv(\n",
121-
" \"https://api.carbonplan.org/projects.csv\", index_col=\"name\"\n",
122-
")\n",
112+
"projects = pd.read_csv(\"https://api.carbonplan.org/projects.csv\", index_col=\"name\")\n",
123113
"projects.head()"
124114
]
125115
},
@@ -141,9 +131,7 @@
141131
"outputs": [],
142132
"source": [
143133
"metrics = [\"cost\", \"volume\", \"negativity\", \"permanence\"]\n",
144-
"metrics_df = pd.DataFrame.from_dict(\n",
145-
" {m: projects[f\"('{m}', 'value')\"] for m in metrics}\n",
146-
")\n",
134+
"metrics_df = pd.DataFrame.from_dict({m: projects[f\"('{m}', 'value')\"] for m in metrics})\n",
147135
"metrics_df[\"tag\"] = projects[\"('tag', 0)\"]\n",
148136
"metrics_df.head()"
149137
]

0 commit comments

Comments
 (0)