Skip to content

Commit

Permalink
updating day13 notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
prakhar21 committed Aug 12, 2018
1 parent 2ba73aa commit 22b5c14
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions day13/Missing Values (Basics).ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,100 @@
"source": [
"df[df[3] == 'UNK']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Imputing by back filling "
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0 0\n",
"1 0\n",
"2 0\n",
"3 0\n",
"4 6\n",
"5 9\n",
"6 9\n",
"7 0\n",
"8 0\n",
"9 0\n",
"10 0\n",
"11 0\n",
"12 0\n",
"13 0\n",
"14 0\n",
"15 0\n",
"dtype: int64"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# we can specify a back-fill to propagate the next values backward\n",
"df[13].fillna(method='bfill', inplace=True)\n",
"df.isnull().sum()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Imputing by forward filling "
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0 0\n",
"1 0\n",
"2 0\n",
"3 0\n",
"4 0\n",
"5 9\n",
"6 9\n",
"7 0\n",
"8 0\n",
"9 0\n",
"10 0\n",
"11 0\n",
"12 0\n",
"13 0\n",
"14 0\n",
"15 0\n",
"dtype: int64"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# We can specify a forward-fill to propagate the previous value forward\n",
"df[4].fillna(method='ffill', inplace=True)\n",
"df.isnull().sum()"
]
}
],
"metadata": {
Expand Down

0 comments on commit 22b5c14

Please sign in to comment.