mirror of
https://github.com/donnemartin/data-science-ipython-notebooks.git
synced 2024-03-22 13:30:56 +08:00
Added numpy IPython Notebook with snippets for NumPy Arrays, dtypes, and shapes.
This commit is contained in:
parent
1d9797b5c5
commit
eef925653d
137
numpy/numpy.ipynb
Normal file
137
numpy/numpy.ipynb
Normal file
|
@ -0,0 +1,137 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "",
|
||||
"signature": "sha256:cb8fc4454a69123dcb745c323968d06c15444cee91494edb720893b06e98c249"
|
||||
},
|
||||
"nbformat": 3,
|
||||
"nbformat_minor": 0,
|
||||
"worksheets": [
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# NumPy\n",
|
||||
"\n",
|
||||
"* NumPy Arrays, dtype, and shape\n",
|
||||
"* Common Array Operations\n",
|
||||
"* Reshaping and In-Place Updating\n",
|
||||
"* Combining Arrays\n",
|
||||
"* Creating Fake Data and Adding Noise"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"import numpy as np"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 1
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## NumPy Arrays, dtypes, and shapes"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"a = np.array([1, 2, 3])\n",
|
||||
"print(a)\n",
|
||||
"print(a.shape)\n",
|
||||
"print(a.dtype)"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"stream": "stdout",
|
||||
"text": [
|
||||
"[1 2 3]\n",
|
||||
"(3,)\n",
|
||||
"int64\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 2
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"b = np.array([[0, 2, 4], [1, 3, 5]])\n",
|
||||
"print(b)\n",
|
||||
"print(b.shape)\n",
|
||||
"print(b.dtype)"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"stream": "stdout",
|
||||
"text": [
|
||||
"[[0 2 4]\n",
|
||||
" [1 3 5]]\n",
|
||||
"(2, 3)\n",
|
||||
"int64\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 3
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"np.zeros(5)"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 4,
|
||||
"text": [
|
||||
"array([ 0., 0., 0., 0., 0.])"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 4
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"np.ones(shape=(3, 4), dtype=np.int32)"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 5,
|
||||
"text": [
|
||||
"array([[1, 1, 1, 1],\n",
|
||||
" [1, 1, 1, 1],\n",
|
||||
" [1, 1, 1, 1]], dtype=int32)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 5
|
||||
}
|
||||
],
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user