Skip to content

Commit

Permalink
Update Lecture4.ipynb
Browse files Browse the repository at this point in the history
Replace O by Li for faster first search. Thanks to Patrick for the tip.
  • Loading branch information
aronwalsh committed Feb 2, 2024
1 parent f55bb01 commit ace126c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Lecture4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
"\n",
"* a band gap between 0.5 and 1.5 eV: `band_gap=(0.5,1.5)`\n",
"* two elements: `num_elements=(2,3)`\n",
"* contains oxygen: `elements=[\"O\"]`\n",
"* contains lithium: `elements=[\"Li\"]`\n",
"\n",
"We want to return the following properties: `material_id`,`formula_pretty` ,`band_gap`, `theoretical`, `is_stable`."
]
Expand Down Expand Up @@ -333,16 +333,16 @@
},
"outputs": [],
"source": [
"# Query for binary and ternary oxides\n",
"# Query for binary and ternary Li compounds with compact output\n",
"with MPRester(FBI_KEY, use_document_model=False) as mpr:\n",
" docs = mpr.materials.summary.search(\n",
" elements=[\"O\"],\n",
" elements=[\"Li\"],\n",
" band_gap=(0.5,1.5),\n",
" num_elements=(2,3),\n",
" fields=['material_id', 'formula_pretty','band_gap','is_stable', 'theoretical']\n",
" )\n",
"\n",
"print(\"Number of binary and ternary oxides with band gap between 0.5 and 1.5 eV: \", len(docs))"
"print(\"Number of binary and ternary Li containing compounds with a band gap between 0.5 and 1.5 eV: \", len(docs))"
]
},
{
Expand Down Expand Up @@ -513,7 +513,7 @@
"source": [
"We now have a DataFrame with the properties that we requested. However, the symmetry is still in dictionary form. This type of issue arises many times in data pre-processing for machine learning models.\n",
"\n",
"The `symmetry` property contains key value pairs of the symmetry data: `number`, `symbol`, `crystal_system`, `point_group`, `source`, `version`. With the exception of `number`, these are all currently `None` as we only requested the property `symmetry.number`. We can convert the `symmetry` into a column of the DataFrame using `.apply()`. This method applies a function to each row of the DataFrame. In this case, we will apply a function that returns the value of the `number` key of the `symmetry` dictionary. "
"The `symmetry` property contains key value pairs of the symmetry data. We can convert the `symmetry` into a column of the DataFrame using `.apply()`. This method applies a function to each row of the DataFrame. In this case, we will apply a function that returns the value of the `number` key of the `symmetry` dictionary. "
]
},
{
Expand All @@ -540,13 +540,13 @@
" \"\"\"\n",
" return symmetry[\"number\"]\n",
"\n",
"# Apply the function to each row of the dataframe\n",
"# Apply the function to each row of the DataFrame\n",
"oxide_df[\"symmetry.number\"] = oxide_df[\"symmetry\"].apply(get_spacegroup_number)\n",
"\n",
"# Drop the \"symmetry\" column from the dataframe\n",
"# Drop the \"symmetry\" column from the DataFrame\n",
"oxide_df.drop(columns=[\"symmetry\"], inplace=True)\n",
"\n",
"# Display the first few rows of the dataframe\n",
"# Display the first few rows of the DataFrame\n",
"oxide_df.head()"
]
},
Expand Down

0 comments on commit ace126c

Please sign in to comment.