{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Examples**
\n",
"Consider 2 Datasets s1 and s2 containing highest clocked speeds of different birds."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"eagle 320.0\n",
"parrot 120.0\n",
"dtype: float64"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s1 = pd.Series({'eagle': 320.0, 'parrot': 120.0})\n",
"s1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
""
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"eagle 335.0\n",
"parrot 180.0\n",
"sparrow 100.0\n",
"dtype: float64"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s2 = pd.Series({'eagle': 335.0, 'parrot': 180.0, 'sparrow': 100.0})\n",
"s2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
""
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "invalid syntax (, line 1)",
"output_type": "error",
"traceback": [
"\u001b[1;36m File \u001b[1;32m\"\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m Now, to combine the two datasets and view the highest speeds of the birds across the two datasets\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
]
}
],
"source": [
"Now, to combine the two datasets and view the highest speeds of the birds across the two datasets"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s1.combine(s2, max)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the previous example, the resulting value for sparrow is missing, because the maximum of a NaN and a float is a NaN.
\n",
"So, in the example, we set fill_value=0, so the maximum value returned will be the value from some dataset."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s1.combine(s2, max, fill_value=0)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}