Skip to content

Instantly share code, notes, and snippets.

@codebrain001
Created April 12, 2020 20:14
Show Gist options
  • Save codebrain001/6acb1ca0a3b58dec1122cff6c315fd1c to your computer and use it in GitHub Desktop.
Save codebrain001/6acb1ca0a3b58dec1122cff6c315fd1c to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Dropping redundant features"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"# dask operation\n",
"dask_df = dask_df.drop('state_po', axis=1)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>year</th>\n",
" <th>state</th>\n",
" <th>county</th>\n",
" <th>FIPS</th>\n",
" <th>office</th>\n",
" <th>candidate</th>\n",
" <th>party</th>\n",
" <th>candidatevotes</th>\n",
" <th>totalvotes</th>\n",
" <th>version</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2016.0</td>\n",
" <td>Alabama</td>\n",
" <td>Autauga</td>\n",
" <td>1001.0</td>\n",
" <td>President</td>\n",
" <td>Hillary Clinton</td>\n",
" <td>democrat</td>\n",
" <td>5936.0</td>\n",
" <td>24973.0</td>\n",
" <td>20190722.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2016.0</td>\n",
" <td>Alabama</td>\n",
" <td>Autauga</td>\n",
" <td>1001.0</td>\n",
" <td>President</td>\n",
" <td>Donald Trump</td>\n",
" <td>republican</td>\n",
" <td>18172.0</td>\n",
" <td>24973.0</td>\n",
" <td>20190722.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2016.0</td>\n",
" <td>Alabama</td>\n",
" <td>Autauga</td>\n",
" <td>1001.0</td>\n",
" <td>President</td>\n",
" <td>Other</td>\n",
" <td>NaN</td>\n",
" <td>865.0</td>\n",
" <td>24973.0</td>\n",
" <td>20190722.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2016.0</td>\n",
" <td>Alabama</td>\n",
" <td>Baldwin</td>\n",
" <td>1003.0</td>\n",
" <td>President</td>\n",
" <td>Hillary Clinton</td>\n",
" <td>democrat</td>\n",
" <td>18458.0</td>\n",
" <td>95215.0</td>\n",
" <td>20190722.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2016.0</td>\n",
" <td>Alabama</td>\n",
" <td>Baldwin</td>\n",
" <td>1003.0</td>\n",
" <td>President</td>\n",
" <td>Donald Trump</td>\n",
" <td>republican</td>\n",
" <td>72883.0</td>\n",
" <td>95215.0</td>\n",
" <td>20190722.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" year state county ... candidatevotes totalvotes version\n",
"0 2016.0 Alabama Autauga ... 5936.0 24973.0 20190722.0\n",
"1 2016.0 Alabama Autauga ... 18172.0 24973.0 20190722.0\n",
"2 2016.0 Alabama Autauga ... 865.0 24973.0 20190722.0\n",
"3 2016.0 Alabama Baldwin ... 18458.0 95215.0 20190722.0\n",
"4 2016.0 Alabama Baldwin ... 72883.0 95215.0 20190722.0\n",
"\n",
"[5 rows x 10 columns]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dask_df.head()"
]
}
],
"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": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment