|
6 | 6 | "source": [
|
7 | 7 | "<p><font size=\"6\"><b> CASE - air quality data of European monitoring stations (AirBase)</b></font></p>\n",
|
8 | 8 | "\n",
|
9 |
| - "> *DS Data manipulation, analysis and visualization in Python* \n", |
10 |
| - "> *May/June, 2021*\n", |
11 |
| - ">\n", |
12 | 9 | "> *© 2021, Joris Van den Bossche and Stijn Van Hoey (<mailto:[email protected]>, <mailto:[email protected]>). Licensed under [CC BY 4.0 Creative Commons](http://creativecommons.org/licenses/by/4.0/)*\n",
|
13 | 10 | "\n",
|
14 | 11 | "---"
|
|
344 | 341 | "cell_type": "code",
|
345 | 342 | "execution_count": 6,
|
346 | 343 | "metadata": {
|
347 |
| - "clear_cell": true |
| 344 | + "tags": [ |
| 345 | + "nbtutor-solution" |
| 346 | + ] |
348 | 347 | },
|
349 | 348 | "outputs": [],
|
350 | 349 | "source": [
|
|
356 | 355 | "cell_type": "code",
|
357 | 356 | "execution_count": 7,
|
358 | 357 | "metadata": {
|
359 |
| - "clear_cell": true, |
360 |
| - "scrolled": true |
| 358 | + "scrolled": true, |
| 359 | + "tags": [ |
| 360 | + "nbtutor-solution" |
| 361 | + ] |
361 | 362 | },
|
362 | 363 | "outputs": [
|
363 | 364 | {
|
|
570 | 571 | "source": [
|
571 | 572 | "<div class=\"alert alert-success\">\n",
|
572 | 573 | "\n",
|
573 |
| - "<b>EXERCISE</b>:\n", |
574 |
| - "<br><br>\n", |
575 |
| - "Drop all 'flag' columns ('flag1', 'flag2', ...)" |
| 574 | + "**EXERCISE**:\n", |
| 575 | + "\n", |
| 576 | + "Drop all 'flag' columns ('flag1', 'flag2', ...)\n", |
| 577 | + "\n", |
| 578 | + "</div>" |
576 | 579 | ]
|
577 | 580 | },
|
578 | 581 | {
|
|
589 | 592 | "cell_type": "code",
|
590 | 593 | "execution_count": 9,
|
591 | 594 | "metadata": {
|
592 |
| - "clear_cell": true, |
593 |
| - "scrolled": true |
| 595 | + "scrolled": true, |
| 596 | + "tags": [ |
| 597 | + "nbtutor-solution" |
| 598 | + ] |
594 | 599 | },
|
595 | 600 | "outputs": [],
|
596 | 601 | "source": [
|
|
912 | 917 | "cell_type": "code",
|
913 | 918 | "execution_count": 11,
|
914 | 919 | "metadata": {
|
915 |
| - "clear_cell": true |
| 920 | + "tags": [ |
| 921 | + "nbtutor-solution" |
| 922 | + ] |
916 | 923 | },
|
917 | 924 | "outputs": [
|
918 | 925 | {
|
|
1006 | 1013 | "cell_type": "code",
|
1007 | 1014 | "execution_count": 12,
|
1008 | 1015 | "metadata": {
|
1009 |
| - "clear_cell": true |
| 1016 | + "tags": [ |
| 1017 | + "nbtutor-solution" |
| 1018 | + ] |
1010 | 1019 | },
|
1011 | 1020 | "outputs": [
|
1012 | 1021 | {
|
|
1038 | 1047 | "cell_type": "code",
|
1039 | 1048 | "execution_count": 13,
|
1040 | 1049 | "metadata": {
|
1041 |
| - "clear_cell": true |
| 1050 | + "tags": [ |
| 1051 | + "nbtutor-solution" |
| 1052 | + ] |
1042 | 1053 | },
|
1043 | 1054 | "outputs": [
|
1044 | 1055 | {
|
|
1134 | 1145 | "cell_type": "code",
|
1135 | 1146 | "execution_count": 14,
|
1136 | 1147 | "metadata": {
|
1137 |
| - "clear_cell": true |
| 1148 | + "tags": [ |
| 1149 | + "nbtutor-solution" |
| 1150 | + ] |
1138 | 1151 | },
|
1139 | 1152 | "outputs": [],
|
1140 | 1153 | "source": [
|
|
1146 | 1159 | "cell_type": "code",
|
1147 | 1160 | "execution_count": 15,
|
1148 | 1161 | "metadata": {
|
1149 |
| - "clear_cell": true |
| 1162 | + "tags": [ |
| 1163 | + "nbtutor-solution" |
| 1164 | + ] |
1150 | 1165 | },
|
1151 | 1166 | "outputs": [
|
1152 | 1167 | {
|
|
1222 | 1237 | "cell_type": "code",
|
1223 | 1238 | "execution_count": 16,
|
1224 | 1239 | "metadata": {
|
1225 |
| - "clear_cell": true |
| 1240 | + "tags": [ |
| 1241 | + "nbtutor-solution" |
| 1242 | + ] |
1226 | 1243 | },
|
1227 | 1244 | "outputs": [],
|
1228 | 1245 | "source": [
|
|
1433 | 1450 | "cell_type": "code",
|
1434 | 1451 | "execution_count": 21,
|
1435 | 1452 | "metadata": {
|
1436 |
| - "clear_cell": true |
| 1453 | + "tags": [ |
| 1454 | + "nbtutor-solution" |
| 1455 | + ] |
1437 | 1456 | },
|
1438 | 1457 | "outputs": [],
|
1439 | 1458 | "source": [
|
|
1525 | 1544 | {
|
1526 | 1545 | "cell_type": "code",
|
1527 | 1546 | "execution_count": 25,
|
1528 |
| - "metadata": { |
1529 |
| - "clear_cell": false |
1530 |
| - }, |
| 1547 | + "metadata": {}, |
1531 | 1548 | "outputs": [
|
1532 | 1549 | {
|
1533 | 1550 | "data": {
|
|
1610 | 1627 | "source": [
|
1611 | 1628 | "<div class=\"alert alert-success\">\n",
|
1612 | 1629 | "\n",
|
1613 |
| - "<b>EXERCISE</b>:\n", |
| 1630 | + "**EXERCISE**:\n", |
1614 | 1631 | "\n",
|
1615 |
| - " <ul>\n", |
1616 |
| - " <li>Use the <code>glob.glob</code> function to list all 4 AirBase data files that are included in the 'data' directory, and call the result <code>data_files</code>.</li>\n", |
1617 |
| - "</ul>\n", |
| 1632 | + "Use the [pathlib module](https://docs.python.org/3/library/pathlib.html) `Path` class in combination with the `glob` method to list all 4 AirBase data files that are included in the 'data' directory, and call the result `data_files`.\n", |
| 1633 | + "\n", |
| 1634 | + "<details><summary>Hints</summary>\n", |
| 1635 | + "\n", |
| 1636 | + "- The pathlib module provides a object oriented way to handle file paths. First, create a `Path` object of the data folder, `pathlib.Path(\"./data\")`. Next, apply the `glob` function to extract all the files containing `*0008001*` (use wildcard * to say \"any characters\"). The output is a Python generator, which you can collect as a `list()`.\n", |
| 1637 | + "\n", |
| 1638 | + "</details> \n", |
| 1639 | + "\n", |
| 1640 | + " \n", |
1618 | 1641 | "</div>"
|
1619 | 1642 | ]
|
1620 | 1643 | },
|
1621 | 1644 | {
|
1622 | 1645 | "cell_type": "code",
|
1623 |
| - "execution_count": 26, |
1624 |
| - "metadata": { |
1625 |
| - "clear_cell": false |
1626 |
| - }, |
| 1646 | + "execution_count": 9, |
| 1647 | + "metadata": {}, |
1627 | 1648 | "outputs": [],
|
1628 | 1649 | "source": [
|
1629 |
| - "import glob" |
| 1650 | + "from pathlib import Path" |
1630 | 1651 | ]
|
1631 | 1652 | },
|
1632 | 1653 | {
|
1633 | 1654 | "cell_type": "code",
|
1634 |
| - "execution_count": 27, |
| 1655 | + "execution_count": 10, |
1635 | 1656 | "metadata": {
|
1636 |
| - "clear_cell": true |
| 1657 | + "tags": [ |
| 1658 | + "nbtutor-solution" |
| 1659 | + ] |
1637 | 1660 | },
|
1638 | 1661 | "outputs": [
|
1639 | 1662 | {
|
1640 | 1663 | "data": {
|
1641 | 1664 | "text/plain": [
|
1642 |
| - "['data/FR040120000800100hour.1-1-1999.31-12-2012',\n", |
1643 |
| - " 'data/FR040370000800100hour.1-1-1999.31-12-2012',\n", |
1644 |
| - " 'data/BETN0290000800100hour.1-1-1990.31-12-2012',\n", |
1645 |
| - " 'data/BETR8010000800100hour.1-1-1990.31-12-2012']" |
| 1665 | + "[PosixPath('data/BETN0290000800100hour.1-1-1990.31-12-2012'),\n", |
| 1666 | + " PosixPath('data/FR040120000800100hour.1-1-1999.31-12-2012'),\n", |
| 1667 | + " PosixPath('data/FR040370000800100hour.1-1-1999.31-12-2012'),\n", |
| 1668 | + " PosixPath('data/BETR8010000800100hour.1-1-1990.31-12-2012')]" |
1646 | 1669 | ]
|
1647 | 1670 | },
|
1648 |
| - "execution_count": 27, |
| 1671 | + "execution_count": 10, |
1649 | 1672 | "metadata": {},
|
1650 | 1673 | "output_type": "execute_result"
|
1651 | 1674 | }
|
1652 | 1675 | ],
|
1653 | 1676 | "source": [
|
1654 |
| - "data_files = glob.glob(\"data/*0008001*\")\n", |
| 1677 | + "data_folder = Path(\"./data\")\n", |
| 1678 | + "data_files = list(data_folder.glob(\"*0008001*\"))\n", |
1655 | 1679 | "data_files"
|
1656 | 1680 | ]
|
1657 | 1681 | },
|
|
1675 | 1699 | "cell_type": "code",
|
1676 | 1700 | "execution_count": 28,
|
1677 | 1701 | "metadata": {
|
1678 |
| - "clear_cell": true |
| 1702 | + "tags": [ |
| 1703 | + "nbtutor-solution" |
| 1704 | + ] |
1679 | 1705 | },
|
1680 | 1706 | "outputs": [],
|
1681 | 1707 | "source": [
|
|
1691 | 1717 | "cell_type": "code",
|
1692 | 1718 | "execution_count": 29,
|
1693 | 1719 | "metadata": {
|
1694 |
| - "clear_cell": true |
| 1720 | + "tags": [ |
| 1721 | + "nbtutor-solution" |
| 1722 | + ] |
1695 | 1723 | },
|
1696 | 1724 | "outputs": [],
|
1697 | 1725 | "source": [
|
|
1816 | 1844 | }
|
1817 | 1845 | ],
|
1818 | 1846 | "metadata": {
|
| 1847 | + "jupytext": { |
| 1848 | + "formats": "ipynb,md:myst" |
| 1849 | + }, |
1819 | 1850 | "kernelspec": {
|
1820 |
| - "display_name": "Python 3", |
| 1851 | + "display_name": "Python 3 (ipykernel)", |
1821 | 1852 | "language": "python",
|
1822 | 1853 | "name": "python3"
|
1823 | 1854 | },
|
|
1831 | 1862 | "name": "python",
|
1832 | 1863 | "nbconvert_exporter": "python",
|
1833 | 1864 | "pygments_lexer": "ipython3",
|
1834 |
| - "version": "3.8.10" |
| 1865 | + "version": "3.9.7" |
1835 | 1866 | },
|
1836 | 1867 | "nav_menu": {},
|
1837 | 1868 | "toc": {
|
|
0 commit comments