Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion book/matplotlib/customize.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion book/matplotlib/histograms.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -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",
Expand Down
10 changes: 1 addition & 9 deletions book/matplotlib/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <b><code>matplotlib</code></b> 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 <b><code>matplotlib</code></b> library we will discuss the following functions:
- <b><code>plt.subplot()</code></b>
- <b><code>plt.plot()</code></b>
Expand All @@ -22,3 +13,4 @@ From the <b><code>matplotlib</code></b> library we will discuss the following fu
- <b><code>plt.grid()</code></b>
- <b><code>plt.show()</code></b>

In addition to `matplotlib`, we will often import Numpy (and occasionally Pandas) to help us with the numerical computations.
5 changes: 3 additions & 2 deletions book/matplotlib/nutshell/nutshell.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
5 changes: 4 additions & 1 deletion book/matplotlib/scatter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
{
"cell_type": "code",
"execution_count": 64,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions book/matplotlib/simple-plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand Down
6 changes: 5 additions & 1 deletion book/matplotlib/subplots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
{
"cell_type": "code",
"execution_count": 60,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -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",
Expand Down
9 changes: 1 addition & 8 deletions book/numpy/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

The <b><code>numpy</code></b> 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 <b><code>numpy</code></b> 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 <b><code>[]</code></b>. Arrays are the <b><code>numpy</code></b> equivalent of lists, with a few characteristic traits:<br><br>- <b><code>numpy</code></b> arrays can only store one type of element,<br>- <b><code>numpy</code></b> arrays take up much less memory than lists,<br>- <b><code>numpy</code></b> arrays have a much better runtime behavior,<br>- it is easier to work with multi-dimensional <b><code>numpy</code></b> arrays than with multi-dimensional lists<br><br>

The following functions will be discussed in this Notebook:
- <b><code>np.array()</code></b>
Expand All @@ -28,8 +26,3 @@ The following functions will be discussed in this Notebook:
- <b><code>np.cos()</code></b>
- <b><code>np.sin()</code></b>
- <b><code>np.sqrt()</code></b>


In Section 2.3, of Notebook 2, you have already encountered lists, which are created with square brackets <b><code>[]</code></b>. Arrays are the <b><code>numpy</code></b> equivalent of lists, with a few characteristic traits:<br><br>- <b><code>numpy</code></b> arrays can only store one type of element,<br>- <b><code>numpy</code></b> arrays take up much less memory than lists,<br>- <b><code>numpy</code></b> arrays have a much better runtime behavior,<br>- it is easier to work with multi-dimensional <b><code>numpy</code></b> arrays than with multi-dimensional lists<br><br>


4 changes: 2 additions & 2 deletions book/numpy/nutshell/numpy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# 5. Numpy"
"# Numpy"
]
},
{
"attachments": {},
"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",
Expand Down
4 changes: 3 additions & 1 deletion book/pandas/attributes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
{
"cell_type": "code",
"execution_count": 66,
"execution_count": null,
"metadata": {
"collapsed": true,
"nbgrader": {
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion book/pandas/frame.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": null,
"metadata": {
"collapsed": true,
"nbgrader": {
Expand All @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion book/pandas/nutshell/frame.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions book/pandas/statistics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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()"
]
},
Expand Down