mirror of
https://github.com/donnemartin/data-science-ipython-notebooks.git
synced 2024-03-22 13:30:56 +08:00
Added snippets for basic Arithmetic and Data Alignment for Series.
This commit is contained in:
parent
c821f2d6f3
commit
c2bf4dfda5
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "",
|
||||
"signature": "sha256:207ce6e6163805a40ff6b55987e709194f2be605d9cc8f7276e2b6d50b096e89"
|
||||
"signature": "sha256:f58e882e3019ecb243505ef140cb0aedee21ecd47d1210ca8e6b4e2281c1316e"
|
||||
},
|
||||
"nbformat": 3,
|
||||
"nbformat_minor": 0,
|
||||
|
@ -18,7 +18,8 @@
|
|||
"* DataFrame\n",
|
||||
"* Reindexing\n",
|
||||
"* Dropping Entries\n",
|
||||
"* Indexing, Selecting, Filtering"
|
||||
"* Indexing, Selecting, Filtering\n",
|
||||
"* Arithmetic and Data Alignment"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -26,7 +27,8 @@
|
|||
"collapsed": false,
|
||||
"input": [
|
||||
"from pandas import Series, DataFrame\n",
|
||||
"import pandas as pd"
|
||||
"import pandas as pd\n",
|
||||
"import numpy as np"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
|
@ -3319,14 +3321,100 @@
|
|||
],
|
||||
"prompt_number": 63
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Arithmetic and Data Alignment"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [],
|
||||
"input": [
|
||||
"ser_6 = Series(np.random.randn(5),\n",
|
||||
" index=['a', 'b', 'c', 'd', 'e'])\n",
|
||||
"ser_6\n"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 63
|
||||
"outputs": [
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 64,
|
||||
"text": [
|
||||
"a -0.224292\n",
|
||||
"b -1.166149\n",
|
||||
"c -2.078194\n",
|
||||
"d 2.060130\n",
|
||||
"e 0.292102\n",
|
||||
"dtype: float64"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 64
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"ser_7 = Series(np.random.randn(5),\n",
|
||||
" index=['a', 'c', 'e', 'f', 'g'])\n",
|
||||
"ser_7"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 65,
|
||||
"text": [
|
||||
"a -0.329560\n",
|
||||
"c 1.009019\n",
|
||||
"e -2.489898\n",
|
||||
"f -0.731142\n",
|
||||
"g -0.025979\n",
|
||||
"dtype: float64"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 65
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Adding objects results in the union of index pairs if the pairs are not the same, resulting in NAs for indices that do not overlap:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"ser_6 + ser_7"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 66,
|
||||
"text": [
|
||||
"a -0.553851\n",
|
||||
"b NaN\n",
|
||||
"c -1.069176\n",
|
||||
"d NaN\n",
|
||||
"e -2.197796\n",
|
||||
"f NaN\n",
|
||||
"g NaN\n",
|
||||
"dtype: float64"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 66
|
||||
}
|
||||
],
|
||||
"metadata": {}
|
||||
|
|
Loading…
Reference in New Issue
Block a user