diff --git a/core/numpy/numpy-basics.ipynb b/core/numpy/numpy-basics.ipynb index 2713c3115..8efbebfd6 100644 --- a/core/numpy/numpy-basics.ipynb +++ b/core/numpy/numpy-basics.ipynb @@ -14,44 +14,30 @@ "metadata": {}, "source": [ "## Overview\n", - "NumPy is the fundamental package for scientific computing with Python. It contains among other things:\n", + "Welcome to your first Python library - NumPy! NumPy is the fundamental package for numerical operations with Python. It contains among other things:\n", "\n", "- a powerful N-dimensional array object\n", "- sophisticated (broadcasting) functions\n", "- useful linear algebra, Fourier transform, and random number capabilities\n", "\n", - "The NumPy array object is the common interface for working with typed arrays of data across a wide-variety of scientific Python packages. NumPy also features a C-API, which enables interfacing existing Fortran/C/C++ libraries with Python and NumPy. In this notebook we will cover\n", + "Let's get you started with the basics! In this notebook we will cover\n", "\n", "1. Creating an `array`\n", "1. Math and calculations with arrays\n", "1. Inspecting an array with slicing and indexing" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Prerequisites\n", - "\n", - "| Concepts | Importance | Notes |\n", - "| --- | --- | --- |\n", - "| [Python Quickstart](../../foundations/quickstart) | Necessary | Lists, indexing, slicing, math |\n", - "\n", - "* **Time to learn**: 35 minutes\n", - "---" - ] - }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Imports\n", - "A common convention you might encounter is to rename `numpy` to `np` on import to shorten it for the many times we will be calling on `numpy` for functionality." + "You need to import packages into your notebook to be able to use them. A common convention you might encounter is to rename `numpy` to `np` on import to shorten it for the many times we will be calling on `numpy` for functionality." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -64,14 +50,25 @@ "source": [ "## Create an array of 'data'\n", "\n", - "The NumPy array represents a *contiguous* block of memory, holding entries of a given type (and hence fixed size). The entries are laid out in memory according to the shape, or list of dimension sizes. Let's start by creating an array from a list of integers and taking a look at it," + "The NumPy array represents a *contiguous* block of memory, holding entries of a given type (and hence fixed size). Let's start by creating an array from a list of integers and taking a look at it," ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1, 2, 3])" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "a = np.array([1, 2, 3])\n", "a" @@ -81,23 +78,45 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We can inspect the number of dimensions our array is organized along with `ndim`, and how long each of these dimensions are with `shape`" + "The entries of the array are laid out in memory according to the shape, or list of dimension sizes. We can inspect the number of dimensions of our array with `ndim`, and how long each of these dimensions are with `shape`. " ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "a.ndim" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(3,)" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "a.shape" ] @@ -106,14 +125,25 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "So our 1-dimensional array has a shape of `3` along that dimension! Finally we can check out the underlying type of our underlying data," + "So our 1-dimensional array has a shape of `3` along that dimension! The dot `(.)` notation helps you access various `properties` of the NumPy array. Finally, we can check out the underlying type of our underlying data," ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "dtype('int64')" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "a.dtype" ] @@ -127,9 +157,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[1., 2., 3.],\n", + " [4., 5., 6.]])" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "a = np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])\n", "a" @@ -137,27 +179,60 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "a.ndim" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(2, 3)" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "a.shape" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "dtype('float64')" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "a.dtype" ] @@ -1025,7 +1100,20 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.2" + "version": "3.7.15" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false }, "toc-autonumbering": false },