mirror of
https://github.com/gsi-upm/sitc
synced 2026-03-03 02:08:17 +00:00
Update 3_2_Pandas.ipynb
Updated to pandas 3.0 and corrected typos
This commit is contained in:
committed by
GitHub
parent
5d01f26e72
commit
ff76909b87
@@ -150,7 +150,7 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# Series with population in 2015 of more populated cities in Spain\n",
|
"# Series with population in 2015 of most populous cities in Spain\n",
|
||||||
"s = Series([3141991, 1604555, 786189, 693878, 664953, 569130], index=['Madrid', 'Barcelona', 'Valencia', 'Sevilla', \n",
|
"s = Series([3141991, 1604555, 786189, 693878, 664953, 569130], index=['Madrid', 'Barcelona', 'Valencia', 'Sevilla', \n",
|
||||||
" 'Zaragoza', 'Malaga'])\n",
|
" 'Zaragoza', 'Malaga'])\n",
|
||||||
"s"
|
"s"
|
||||||
@@ -177,7 +177,7 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"Until now, we have not seen any advantage in using Panda Series. we are going to show now some examples of their possibilities."
|
"Until now, we have not seen any advantage in using Panda Series. We are going to show some examples of their possibilities."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -204,7 +204,7 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"Observe that (s > 1000000) returns a Series object. We can use this boolean vector as a filter to get a *slice* of the original series that contains only the elements where the value of the filter is True. The original Series s is not modified. This selection is called *boolean indexing*."
|
"Observe that (s > 1000000) returns a Series object. We can use this Boolean vector as a filter to obtain a slice of the original series containing only the elements where the filter evaluates to True. The original Series s is not modified. This selection is called *boolean indexing*."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -323,7 +323,7 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"We can also change values directly or based on a condition. You can consult additional feautures in the manual."
|
"We can also change values directly or based on a condition. You can consult additional features in the manual."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -344,7 +344,8 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# Increase by 10% cities with population greater than 700000\n",
|
"# Increase by 10% cities with population greater than 700000\n",
|
||||||
"s[s > 700000] = 1.1 * s[s > 700000]\n",
|
"# Since pandas 3.X use where\n",
|
||||||
|
"s = s.where(s <= 700000, s * 1.1)\n",
|
||||||
"s"
|
"s"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -449,7 +450,7 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
|
"The notebook is freely licensed under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
|
||||||
"\n",
|
"\n",
|
||||||
"© Carlos A. Iglesias, Universidad Politécnica de Madrid."
|
"© Carlos A. Iglesias, Universidad Politécnica de Madrid."
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user