diff --git a/book/matplotlib/customize.ipynb b/book/matplotlib/customize.ipynb index 72fa842..8db3c45 100644 --- a/book/matplotlib/customize.ipynb +++ b/book/matplotlib/customize.ipynb @@ -12,7 +12,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -27,6 +27,9 @@ } ], "source": [ + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", "plt.figure(figsize=(4,2))\n", "plt.plot(x, y, linestyle='--', linewidth=5, color='r')\n", "plt.xlim(2, 8) \n", diff --git a/book/matplotlib/histograms.ipynb b/book/matplotlib/histograms.ipynb index f344bfc..52f5ce3 100644 --- a/book/matplotlib/histograms.ipynb +++ b/book/matplotlib/histograms.ipynb @@ -14,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -29,6 +29,9 @@ } ], "source": [ + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", "earthquake_magnitudes = [4.5, 5.2, 4.8, 5.7, 4.9, 6.2, 5.1,\n", " 5.5, 4.6, 5.9, 5.3, 4.7, 5.8, 4.4,\n", " 4.8, 5.1, 5.3, 5.2, 4.9, 5.4, 5.6]\n", diff --git a/book/matplotlib/intro.md b/book/matplotlib/intro.md index c742e3a..605af63 100644 --- a/book/matplotlib/intro.md +++ b/book/matplotlib/intro.md @@ -2,15 +2,6 @@ Matplotlib is a Python module that allows you to create visualizations. Until now, you have probably used Excel to make graphs, but Python offers much more versatility. In this section, you will learn how to use matplotlib to make good-looking graphs. -As always, let's import the module. We will also import numpy and pandas. - - -```python -import matplotlib.pyplot as plt -import numpy as np -import pandas as pd -``` - From the matplotlib library we will discuss the following functions: - plt.subplot() - plt.plot() @@ -22,3 +13,4 @@ From the matplotlib library we will discuss the following fu - plt.grid() - plt.show() +In addition to `matplotlib`, we will often import Numpy (and occasionally Pandas) to help us with the numerical computations. \ No newline at end of file diff --git a/book/matplotlib/nutshell/nutshell.ipynb b/book/matplotlib/nutshell/nutshell.ipynb index fbf93dd..aa251ad 100644 --- a/book/matplotlib/nutshell/nutshell.ipynb +++ b/book/matplotlib/nutshell/nutshell.ipynb @@ -14,11 +14,12 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "import matplotlib.pyplot as plt" + "import matplotlib.pyplot as plt\n", + "import numpy as np" ] }, { diff --git a/book/matplotlib/scatter.ipynb b/book/matplotlib/scatter.ipynb index 2b19a68..081e4bb 100644 --- a/book/matplotlib/scatter.ipynb +++ b/book/matplotlib/scatter.ipynb @@ -24,7 +24,7 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -39,6 +39,9 @@ } ], "source": [ + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", "curing_time = [3,7,14,21,28]\n", "compressive_strength = [10,20,30,40,50]\n", "\n", diff --git a/book/matplotlib/simple-plot.ipynb b/book/matplotlib/simple-plot.ipynb index 0c6455c..faf50d9 100644 --- a/book/matplotlib/simple-plot.ipynb +++ b/book/matplotlib/simple-plot.ipynb @@ -6,12 +6,12 @@ "metadata": {}, "source": [ "## Simple plot\n", - "Let's start by creating a simple line plot of the equation $y=3x+5$. We will use numpy to create an array which acts as our x-axis" + "After importing the necessary packages, let's start by creating a simple line plot of the equation $y=3x+5$. We will use numpy to create an array which acts as our x-axis" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": { "collapsed": true, "nbgrader": { @@ -33,6 +33,9 @@ } ], "source": [ + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", "x = np.linspace(0,10)\n", "y = 3*x + 5\n", "\n", diff --git a/book/matplotlib/subplots.ipynb b/book/matplotlib/subplots.ipynb index 84b0320..083b029 100644 --- a/book/matplotlib/subplots.ipynb +++ b/book/matplotlib/subplots.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -109,6 +109,10 @@ } ], "source": [ + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "import pandas as pd\n", + "\n", "dataset = pd.read_csv(\"https://raw.githubusercontent.com/\"\n", " \"mike-mendoza/Bivariate_NPBN_workshop_files/\"\n", " \"a991bc3d9391a92437af1c3d69ae9fdfe6baf6da/\"\n", diff --git a/book/numpy/intro.md b/book/numpy/intro.md index 823006d..467bcf9 100644 --- a/book/numpy/intro.md +++ b/book/numpy/intro.md @@ -2,9 +2,7 @@ The numpy package is one of the main packages when it comes to working with arrays and matrices in Python, making it indispensable to process and visualize scientific data. Its assortment of routines facilitates operations such as mathematical, logical, linear algebra, Fourier transforms, and much more. In this section, you will learn some of the most used numpy functions to work with multidimensional array objects. -As always, let's import the package we will use - -`import numpy as np` +Previously in this course you have already encountered _lists,_ which are created with square brackets []. Arrays are the numpy equivalent of lists, with a few characteristic traits:

- numpy arrays can only store one type of element,
- numpy arrays take up much less memory than lists,
- numpy arrays have a much better runtime behavior,
- it is easier to work with multi-dimensional numpy arrays than with multi-dimensional lists

The following functions will be discussed in this Notebook: - np.array() @@ -28,8 +26,3 @@ The following functions will be discussed in this Notebook: - np.cos() - np.sin() - np.sqrt() - - -In Section 2.3, of Notebook 2, you have already encountered lists, which are created with square brackets []. Arrays are the numpy equivalent of lists, with a few characteristic traits:

- numpy arrays can only store one type of element,
- numpy arrays take up much less memory than lists,
- numpy arrays have a much better runtime behavior,
- it is easier to work with multi-dimensional numpy arrays than with multi-dimensional lists

- - diff --git a/book/numpy/nutshell/numpy.ipynb b/book/numpy/nutshell/numpy.ipynb index 3c4f239..a2a65bf 100644 --- a/book/numpy/nutshell/numpy.ipynb +++ b/book/numpy/nutshell/numpy.ipynb @@ -5,7 +5,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 5. Numpy" + "# Numpy" ] }, { @@ -13,7 +13,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 5.1. Introduction\n", + "## Introduction\n", "\n", "The `numpy` package is essential for handling arrays and matrices in Python, making it invaluable for processing and visualizing scientific data. It offers a wide range of functions for various operations, including mathematics, logic, linear algebra, Fourier transforms, and more. In this section, you will explore commonly used numpy functions to work with multidimensional arrays.\n", "\n", diff --git a/book/pandas/attributes.ipynb b/book/pandas/attributes.ipynb index 45a7b36..99e42db 100644 --- a/book/pandas/attributes.ipynb +++ b/book/pandas/attributes.ipynb @@ -36,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 66, + "execution_count": null, "metadata": { "collapsed": true, "nbgrader": { @@ -178,6 +178,8 @@ } ], "source": [ + "import pandas as pd\n", + "\n", "file_location = (\"mineral_properties.txt\")\n", "df4 = pd.read_csv(file_location, sep=',', header=[1],\n", " skiprows=None, index_col=0)\n", diff --git a/book/pandas/frame.ipynb b/book/pandas/frame.ipynb index ec94da5..e010d9e 100644 --- a/book/pandas/frame.ipynb +++ b/book/pandas/frame.ipynb @@ -39,7 +39,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": null, "metadata": { "collapsed": true, "nbgrader": { @@ -53,6 +53,8 @@ }, "outputs": [], "source": [ + "import pandas as pd\n", + "\n", "row_1 = pd.Series(['Garnet', 7.0, 'Fracture', 3.9 ])\n", "row_2 = pd.Series(['Graphite', 1.5, 'One', 2.3 ])\n", "row_3 = pd.Series(['Kyanite', 6, 'One', 4.01 ])\n", diff --git a/book/pandas/nutshell/frame.ipynb b/book/pandas/nutshell/frame.ipynb index 0b3474d..2e564ac 100644 --- a/book/pandas/nutshell/frame.ipynb +++ b/book/pandas/nutshell/frame.ipynb @@ -11,7 +11,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -83,6 +83,8 @@ } ], "source": [ + "import pandas as pd\n", + "\n", "data2 = {'Name': ['John', 'Alice', 'Bob'],\n", " 'Age': [25, 28, 22],\n", " 'City': ['London', 'Paris', 'Berlin']}\n", diff --git a/book/pandas/statistics.ipynb b/book/pandas/statistics.ipynb index 6166b3f..ed10e6a 100644 --- a/book/pandas/statistics.ipynb +++ b/book/pandas/statistics.ipynb @@ -40,6 +40,12 @@ } ], "source": [ + "import pandas as pd\n", + "file_location = (\"mineral_properties.txt\")\n", + "df4 = pd.read_csv(file_location + 'mineral_properties.txt',sep=',',header=[1], \n", + " skiprows=None, index_col=0, skipinitialspace=True)\n", + " \n", + "\n", "df4['hardness'].mean()" ] },