-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a60b57
commit 3fee5d2
Showing
3 changed files
with
539 additions
and
435 deletions.
There are no files selected for viewing
Binary file not shown.
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,298 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "670e8412-b0fc-4fe0-9ec0-e2e104e4827d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "3d2a97e4-5fca-48f3-84db-2e65e839de55", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"file_path = 'SI_2_Material_requirements.xlsx'\n", | ||
"xls = pd.ExcelFile(file_path)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "8bdf6ed4-ae0d-44d1-b0cf-537b4d27f976", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"sheets_to_exclude = [\"Materials\", \"Technologies\", \"References\"]\n", | ||
"sheets_to_include = [sheet for sheet in xls.sheet_names if sheet not in sheets_to_exclude]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "b7d94a6b-95ea-45ab-80e1-8f95b1ff5bd3", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"combined_df = pd.DataFrame(columns=[\"metal\", \"unit\", \"year\", \"mean\", \"median\", \"min\", \"max\", \"origin_var\"])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "2b2520af-a5fb-43d5-a9c4-60db6b5531de", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"C:\\Users\\hahnme_a\\AppData\\Local\\Temp\\ipykernel_20220\\936690025.py:8: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.\n", | ||
" combined_df = pd.concat([combined_df, df], ignore_index=True)\n" | ||
] | ||
}, | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<div>\n", | ||
"<style scoped>\n", | ||
" .dataframe tbody tr th:only-of-type {\n", | ||
" vertical-align: middle;\n", | ||
" }\n", | ||
"\n", | ||
" .dataframe tbody tr th {\n", | ||
" vertical-align: top;\n", | ||
" }\n", | ||
"\n", | ||
" .dataframe thead th {\n", | ||
" text-align: right;\n", | ||
" }\n", | ||
"</style>\n", | ||
"<table border=\"1\" class=\"dataframe\">\n", | ||
" <thead>\n", | ||
" <tr style=\"text-align: right;\">\n", | ||
" <th></th>\n", | ||
" <th>metal</th>\n", | ||
" <th>unit</th>\n", | ||
" <th>year</th>\n", | ||
" <th>mean</th>\n", | ||
" <th>median</th>\n", | ||
" <th>min</th>\n", | ||
" <th>max</th>\n", | ||
" <th>origin_var</th>\n", | ||
" </tr>\n", | ||
" </thead>\n", | ||
" <tbody>\n", | ||
" <tr>\n", | ||
" <th>0</th>\n", | ||
" <td>Aluminium</td>\n", | ||
" <td>kg metal/kg vehicle</td>\n", | ||
" <td>2020.0</td>\n", | ||
" <td>0.245611</td>\n", | ||
" <td>0.245611</td>\n", | ||
" <td>2.456112e-01</td>\n", | ||
" <td>0.245611</td>\n", | ||
" <td>ICEV</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>1</th>\n", | ||
" <td>Antimony</td>\n", | ||
" <td>kg metal/kg vehicle</td>\n", | ||
" <td>2020.0</td>\n", | ||
" <td>0.001169</td>\n", | ||
" <td>0.001134</td>\n", | ||
" <td>7.428823e-04</td>\n", | ||
" <td>0.001660</td>\n", | ||
" <td>ICEV</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>2</th>\n", | ||
" <td>Beryllium</td>\n", | ||
" <td>kg metal/kg vehicle</td>\n", | ||
" <td>2020.0</td>\n", | ||
" <td>0.000003</td>\n", | ||
" <td>0.000003</td>\n", | ||
" <td>1.620822e-06</td>\n", | ||
" <td>0.000004</td>\n", | ||
" <td>ICEV</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>3</th>\n", | ||
" <td>Cerium</td>\n", | ||
" <td>kg metal/kg vehicle</td>\n", | ||
" <td>2020.0</td>\n", | ||
" <td>0.000016</td>\n", | ||
" <td>0.000013</td>\n", | ||
" <td>1.550000e-07</td>\n", | ||
" <td>0.000049</td>\n", | ||
" <td>ICEV</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>4</th>\n", | ||
" <td>Cobalt</td>\n", | ||
" <td>kg metal/kg vehicle</td>\n", | ||
" <td>2020.0</td>\n", | ||
" <td>0.003039</td>\n", | ||
" <td>0.003562</td>\n", | ||
" <td>1.948080e-03</td>\n", | ||
" <td>0.003737</td>\n", | ||
" <td>ICEV</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>...</th>\n", | ||
" <td>...</td>\n", | ||
" <td>...</td>\n", | ||
" <td>...</td>\n", | ||
" <td>...</td>\n", | ||
" <td>...</td>\n", | ||
" <td>...</td>\n", | ||
" <td>...</td>\n", | ||
" <td>...</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>236</th>\n", | ||
" <td>Praseodimium</td>\n", | ||
" <td>kg/MW</td>\n", | ||
" <td>2020.0</td>\n", | ||
" <td>8.784196</td>\n", | ||
" <td>8.784196</td>\n", | ||
" <td>8.784196e+00</td>\n", | ||
" <td>8.784196</td>\n", | ||
" <td>HTEL - Yttrium</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>237</th>\n", | ||
" <td>Strontium</td>\n", | ||
" <td>kg/MW</td>\n", | ||
" <td>2020.0</td>\n", | ||
" <td>2.737974</td>\n", | ||
" <td>2.396332</td>\n", | ||
" <td>1.616888e+00</td>\n", | ||
" <td>4.200702</td>\n", | ||
" <td>HTEL - Yttrium</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>238</th>\n", | ||
" <td>Yttrium</td>\n", | ||
" <td>kg/MW</td>\n", | ||
" <td>2020.0</td>\n", | ||
" <td>50.875605</td>\n", | ||
" <td>65.997099</td>\n", | ||
" <td>1.156334e+01</td>\n", | ||
" <td>75.066370</td>\n", | ||
" <td>HTEL - Yttrium</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>239</th>\n", | ||
" <td>Zirconium</td>\n", | ||
" <td>kg/MW</td>\n", | ||
" <td>2020.0</td>\n", | ||
" <td>242.987230</td>\n", | ||
" <td>271.390647</td>\n", | ||
" <td>6.822289e+01</td>\n", | ||
" <td>389.348155</td>\n", | ||
" <td>HTEL - Yttrium</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>240</th>\n", | ||
" <td>Yttrium</td>\n", | ||
" <td>kg/MW</td>\n", | ||
" <td>2050.0</td>\n", | ||
" <td>6.016672</td>\n", | ||
" <td>6.016672</td>\n", | ||
" <td>4.700000e-01</td>\n", | ||
" <td>11.563345</td>\n", | ||
" <td>HTEL - Yttrium</td>\n", | ||
" </tr>\n", | ||
" </tbody>\n", | ||
"</table>\n", | ||
"<p>241 rows × 8 columns</p>\n", | ||
"</div>" | ||
], | ||
"text/plain": [ | ||
" metal unit year mean median \\\n", | ||
"0 Aluminium kg metal/kg vehicle 2020.0 0.245611 0.245611 \n", | ||
"1 Antimony kg metal/kg vehicle 2020.0 0.001169 0.001134 \n", | ||
"2 Beryllium kg metal/kg vehicle 2020.0 0.000003 0.000003 \n", | ||
"3 Cerium kg metal/kg vehicle 2020.0 0.000016 0.000013 \n", | ||
"4 Cobalt kg metal/kg vehicle 2020.0 0.003039 0.003562 \n", | ||
".. ... ... ... ... ... \n", | ||
"236 Praseodimium kg/MW 2020.0 8.784196 8.784196 \n", | ||
"237 Strontium kg/MW 2020.0 2.737974 2.396332 \n", | ||
"238 Yttrium kg/MW 2020.0 50.875605 65.997099 \n", | ||
"239 Zirconium kg/MW 2020.0 242.987230 271.390647 \n", | ||
"240 Yttrium kg/MW 2050.0 6.016672 6.016672 \n", | ||
"\n", | ||
" min max origin_var \n", | ||
"0 2.456112e-01 0.245611 ICEV \n", | ||
"1 7.428823e-04 0.001660 ICEV \n", | ||
"2 1.620822e-06 0.000004 ICEV \n", | ||
"3 1.550000e-07 0.000049 ICEV \n", | ||
"4 1.948080e-03 0.003737 ICEV \n", | ||
".. ... ... ... \n", | ||
"236 8.784196e+00 8.784196 HTEL - Yttrium \n", | ||
"237 1.616888e+00 4.200702 HTEL - Yttrium \n", | ||
"238 1.156334e+01 75.066370 HTEL - Yttrium \n", | ||
"239 6.822289e+01 389.348155 HTEL - Yttrium \n", | ||
"240 4.700000e-01 11.563345 HTEL - Yttrium \n", | ||
"\n", | ||
"[241 rows x 8 columns]" | ||
] | ||
}, | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"for sheet in sheets_to_include:\n", | ||
" df = pd.read_excel(file_path, sheet_name=sheet, skiprows=2, header=None, usecols=\"A:G\")\n", | ||
" df.columns = ['metal', 'unit', 'year', 'mean', 'median', 'min', 'max']\n", | ||
" df = df.dropna(how='all')\n", | ||
" df = df[df['metal'] != 'mean']\n", | ||
" df[\"origin_var\"] = sheet\n", | ||
" \n", | ||
" combined_df = pd.concat([combined_df, df], ignore_index=True)\n", | ||
" \n", | ||
"combined_df" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "6bc56cef-de5e-48a6-983c-17f4519dd7c1", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"output_file = 'metals_db.csv'\n", | ||
"combined_df.to_csv(output_file, index=False)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.