Commit 389d2d5f by Paktalin

Section 3 done

parent b86bbb5b
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"X = []"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[1.79302012e+01, 9.45205920e+01, 3.20259530e+02],\n",
" [9.71446972e+01, 6.95932820e+01, 4.04634472e+02],\n",
" [8.17759008e+01, 5.73764810e+00, 1.81485108e+02],\n",
" [5.58543424e+01, 7.03259017e+01, 3.21773638e+02],\n",
" [4.93665500e+01, 7.51140402e+01, 3.22465486e+02],\n",
" [3.19270247e+00, 2.92562989e+01, 9.46188109e+01],\n",
" [4.92007841e+01, 8.61444385e+01, 3.56348093e+02],\n",
" [2.18828039e+01, 4.68415052e+01, 1.81653769e+02],\n",
" [7.95098627e+01, 8.73973555e+01, 4.23557743e+02],\n",
" [8.81538875e+01, 6.52056419e+01, 3.69229245e+02],\n",
" [6.07438543e+01, 9.99576339e+01, 4.27605804e+02],\n",
" [6.74155819e+01, 5.03683096e+01, 2.92471822e+02],\n",
" [4.83181158e+01, 9.91289531e+01, 3.95529811e+02],\n",
" [2.88299720e+01, 8.71849489e+01, 3.19031348e+02],\n",
" [4.38537427e+01, 6.44736391e+01, 2.87428144e+02],\n",
" [2.53136941e+01, 8.35452943e+01, 2.92768909e+02],\n",
" [1.08077267e+01, 4.56955686e+01, 1.59663308e+02],\n",
" [9.83657459e+01, 8.26973935e+01, 4.38798964e+02],\n",
" [2.91469100e+01, 6.63651068e+01, 2.50986309e+02],\n",
" [6.51003019e+01, 3.33538835e+01, 2.31711508e+02],\n",
" [2.46441135e+01, 3.95400527e+01, 1.63398161e+02],\n",
" [3.75598049e+01, 1.34572784e+00, 8.34801551e+01],\n",
" [8.81645062e+01, 9.51536626e+01, 4.66265806e+02],\n",
" [1.38346208e+01, 2.54940482e+01, 1.00886430e+02],\n",
" [6.44108437e+01, 7.72598381e+01, 3.65641048e+02],\n",
" [6.89259918e+01, 9.74536008e+01, 4.26140015e+02],\n",
" [3.94884422e+01, 5.08561282e+01, 2.35532389e+02],\n",
" [5.24631777e+01, 5.97765097e+01, 2.83291640e+02],\n",
" [4.84847870e+01, 6.69703542e+01, 2.98581440e+02],\n",
" [8.06208781e+00, 9.82426001e+01, 3.09234109e+02],\n",
" [3.27318877e+01, 1.88535355e+01, 1.29610139e+02],\n",
" [1.16523788e+01, 6.62645117e+01, 2.24150542e+02],\n",
" [1.37303535e+01, 7.04725091e+01, 2.35305666e+02],\n",
" [8.18555177e+00, 4.18519894e+01, 1.53484189e+02],\n",
" [5.36098761e+01, 9.45601216e+01, 3.94939444e+02],\n",
" [9.53686099e+01, 4.72955070e+01, 3.36126739e+02],\n",
" [8.73336092e+01, 9.38039343e+01, 4.49363352e+02],\n",
" [6.63576111e+01, 8.18475513e+01, 3.87014816e+02],\n",
" [1.97547175e+01, 6.55233009e+01, 2.40389442e+02],\n",
" [2.11334405e+01, 4.74371820e+01, 1.77148281e+02],\n",
" [2.23738648e+01, 2.59556275e+01, 1.19611258e+02],\n",
" [9.39904041e+01, 1.27890520e-01, 1.96716167e+02],\n",
" [8.67201981e+01, 1.84137668e+01, 2.36260808e+02],\n",
" [9.89983730e+01, 6.02312657e+01, 3.84381345e+02],\n",
" [3.59396564e+00, 9.62522173e+01, 2.93237183e+02],\n",
" [1.51023634e+01, 9.25569036e+01, 3.04890883e+02],\n",
" [9.78341408e+01, 2.02390810e+00, 2.01293598e+02],\n",
" [1.99382197e+01, 4.67782735e+01, 1.70610093e+02],\n",
" [3.03735111e+01, 5.87775252e+01, 2.42373484e+02],\n",
" [7.32928831e+01, 6.76696278e+01, 3.53082991e+02],\n",
" [5.22309009e+01, 8.19024483e+01, 3.48725689e+02],\n",
" [8.64295761e+01, 6.65402276e+01, 3.65959971e+02],\n",
" [9.34008021e+01, 1.80752459e+01, 2.35472382e+02],\n",
" [1.32134601e+01, 9.14888588e+01, 3.00606878e+02],\n",
" [4.59346270e+00, 4.63359315e+01, 1.45818745e+02],\n",
" [1.56692916e+01, 3.55437440e+01, 1.38880335e+02],\n",
" [5.29593598e+01, 6.87202096e+01, 3.17163708e+02],\n",
" [5.68175212e+01, 4.75727319e+01, 2.54903631e+02],\n",
" [5.11335431e+01, 7.80421675e+01, 3.34584334e+02],\n",
" [7.86216472e+00, 1.77290818e+01, 6.93555888e+01],\n",
" [5.46986037e+01, 9.27445841e+01, 3.86859937e+02],\n",
" [8.63990630e+01, 4.18886946e+01, 2.94871714e+02],\n",
" [1.19475060e+01, 4.29613867e+01, 1.56754220e+02],\n",
" [7.03584011e+01, 8.37062345e+01, 3.91806135e+02],\n",
" [2.90223663e+01, 8.43277831e+01, 3.19310463e+02],\n",
" [4.27594799e+01, 9.74933261e+01, 3.76291589e+02],\n",
" [9.62156564e+01, 2.58342826e+01, 2.80617044e+02],\n",
" [5.32277277e+01, 2.79055086e+01, 1.94430465e+02],\n",
" [3.03609897e+01, 9.39644215e-01, 6.96488632e+01],\n",
" [8.32775654e+01, 7.31793486e+01, 3.84597185e+02],\n",
" [3.01876925e+01, 7.14653860e+00, 8.95390084e+01],\n",
" [1.17884185e+01, 5.16977608e+01, 1.81550683e+02],\n",
" [1.82924240e+01, 6.19779760e+01, 2.24773383e+02],\n",
" [9.67126677e+01, 9.02910151e+00, 2.19567094e+02],\n",
" [3.10127387e+01, 7.82833825e+01, 2.98490216e+02],\n",
" [1.13972608e+01, 6.17286932e+01, 1.99944045e+02],\n",
" [1.73925558e+01, 4.24114086e+00, 4.39156924e+01],\n",
" [7.21826937e+01, 3.45390722e+01, 2.56068378e+02],\n",
" [7.39800208e+01, 3.71649344e+00, 1.59372581e+02],\n",
" [9.44930584e+01, 8.84171970e+01, 4.47132704e+02],\n",
" [8.45628207e+01, 2.02411622e+01, 2.33078830e+02],\n",
" [5.17424740e+01, 1.10097480e+01, 1.31070180e+02],\n",
" [5.37485904e+01, 6.00251023e+01, 2.98814333e+02],\n",
" [8.50508348e+01, 9.57369970e+01, 4.51803523e+02],\n",
" [4.67772505e+01, 9.02022062e+01, 3.68366436e+02],\n",
" [4.97584342e+01, 5.28344944e+01, 2.54706774e+02],\n",
" [2.41192565e+01, 4.21028108e+01, 1.68308433e+02],\n",
" [2.72015765e+01, 2.99787493e+01, 1.46342260e+02],\n",
" [7.00959617e+00, 5.58760584e+01, 1.76810149e+02],\n",
" [9.76469497e+01, 8.14762513e+00, 2.19160280e+02],\n",
" [1.38298251e+00, 8.49440869e+01, 2.52905653e+02],\n",
" [2.23235304e+01, 2.75150750e+01, 1.27570479e+02],\n",
" [4.50454062e+01, 9.35204022e+01, 3.75822340e+02],\n",
" [4.01639915e+01, 1.61699235e-01, 8.03890193e+01],\n",
" [5.31827398e+01, 8.17031616e+00, 1.42718183e+02],\n",
" [4.64567792e+01, 8.20001709e+01, 3.36876154e+02],\n",
" [7.71303007e+01, 9.51887595e+01, 4.38460586e+02],\n",
" [6.86006076e+01, 7.25711807e+01, 3.55900287e+02],\n",
" [4.16938871e+01, 6.92411260e+01, 2.84834637e+02],\n",
" [4.14266940e+00, 5.22547264e+01, 1.68034401e+02]])"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"for line in open(\"data_2d.csv\"):\n",
" row = line.split(',')\n",
" # print(row)\n",
" sample = list(map(float, row))\n",
" X.append(sample)\n",
"X = np.array(X)\n",
"X"
]
}
],
"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.5.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pandas.core.frame.DataFrame"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X = pd.read_csv(\"data_2d.csv\", header=None)\n",
"type(X)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 100 entries, 0 to 99\n",
"Data columns (total 3 columns):\n",
"0 100 non-null float64\n",
"1 100 non-null float64\n",
"2 100 non-null float64\n",
"dtypes: float64(3)\n",
"memory usage: 2.4 KB\n"
]
}
],
"source": [
"X.info()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"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>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>17.930201</td>\n",
" <td>94.520592</td>\n",
" <td>320.259530</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>97.144697</td>\n",
" <td>69.593282</td>\n",
" <td>404.634472</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>81.775901</td>\n",
" <td>5.737648</td>\n",
" <td>181.485108</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>55.854342</td>\n",
" <td>70.325902</td>\n",
" <td>321.773638</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>49.366550</td>\n",
" <td>75.114040</td>\n",
" <td>322.465486</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 1 2\n",
"0 17.930201 94.520592 320.259530\n",
"1 97.144697 69.593282 404.634472\n",
"2 81.775901 5.737648 181.485108\n",
"3 55.854342 70.325902 321.773638\n",
"4 49.366550 75.114040 322.465486"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X.head()"
]
},
{
"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>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>17.930201</td>\n",
" <td>94.520592</td>\n",
" <td>320.259530</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>97.144697</td>\n",
" <td>69.593282</td>\n",
" <td>404.634472</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>81.775901</td>\n",
" <td>5.737648</td>\n",
" <td>181.485108</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>55.854342</td>\n",
" <td>70.325902</td>\n",
" <td>321.773638</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>49.366550</td>\n",
" <td>75.114040</td>\n",
" <td>322.465486</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>3.192702</td>\n",
" <td>29.256299</td>\n",
" <td>94.618811</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>49.200784</td>\n",
" <td>86.144439</td>\n",
" <td>356.348093</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>21.882804</td>\n",
" <td>46.841505</td>\n",
" <td>181.653769</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>79.509863</td>\n",
" <td>87.397356</td>\n",
" <td>423.557743</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>88.153887</td>\n",
" <td>65.205642</td>\n",
" <td>369.229245</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 1 2\n",
"0 17.930201 94.520592 320.259530\n",
"1 97.144697 69.593282 404.634472\n",
"2 81.775901 5.737648 181.485108\n",
"3 55.854342 70.325902 321.773638\n",
"4 49.366550 75.114040 322.465486\n",
"5 3.192702 29.256299 94.618811\n",
"6 49.200784 86.144439 356.348093\n",
"7 21.882804 46.841505 181.653769\n",
"8 79.509863 87.397356 423.557743\n",
"9 88.153887 65.205642 369.229245"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X.head(10)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.5.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 3,
"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>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>17.930201</td>\n",
" <td>94.520592</td>\n",
" <td>320.259530</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>97.144697</td>\n",
" <td>69.593282</td>\n",
" <td>404.634472</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>81.775901</td>\n",
" <td>5.737648</td>\n",
" <td>181.485108</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>55.854342</td>\n",
" <td>70.325902</td>\n",
" <td>321.773638</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>49.366550</td>\n",
" <td>75.114040</td>\n",
" <td>322.465486</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 1 2\n",
"0 17.930201 94.520592 320.259530\n",
"1 97.144697 69.593282 404.634472\n",
"2 81.775901 5.737648 181.485108\n",
"3 55.854342 70.325902 321.773638\n",
"4 49.366550 75.114040 322.465486"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X = pd.read_csv(\"data_2d.csv\", header=None)\n",
"X.head()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\litak\\Anaconda3\\envs\\tensorflow-cpu\\lib\\site-packages\\ipykernel_launcher.py:1: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead.\n",
" \"\"\"Entry point for launching an IPython kernel.\n"
]
},
{
"data": {
"text/plain": [
"numpy.ndarray"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"M = X.as_matrix()\n",
"type(M)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 17.930201\n",
"1 97.144697\n",
"2 81.775901\n",
"3 55.854342\n",
"4 49.366550\n",
"5 3.192702\n",
"6 49.200784\n",
"7 21.882804\n",
"8 79.509863\n",
"9 88.153887\n",
"10 60.743854\n",
"11 67.415582\n",
"12 48.318116\n",
"13 28.829972\n",
"14 43.853743\n",
"15 25.313694\n",
"16 10.807727\n",
"17 98.365746\n",
"18 29.146910\n",
"19 65.100302\n",
"20 24.644113\n",
"21 37.559805\n",
"22 88.164506\n",
"23 13.834621\n",
"24 64.410844\n",
"25 68.925992\n",
"26 39.488442\n",
"27 52.463178\n",
"28 48.484787\n",
"29 8.062088\n",
" ... \n",
"70 30.187692\n",
"71 11.788418\n",
"72 18.292424\n",
"73 96.712668\n",
"74 31.012739\n",
"75 11.397261\n",
"76 17.392556\n",
"77 72.182694\n",
"78 73.980021\n",
"79 94.493058\n",
"80 84.562821\n",
"81 51.742474\n",
"82 53.748590\n",
"83 85.050835\n",
"84 46.777250\n",
"85 49.758434\n",
"86 24.119257\n",
"87 27.201576\n",
"88 7.009596\n",
"89 97.646950\n",
"90 1.382983\n",
"91 22.323530\n",
"92 45.045406\n",
"93 40.163991\n",
"94 53.182740\n",
"95 46.456779\n",
"96 77.130301\n",
"97 68.600608\n",
"98 41.693887\n",
"99 4.142669\n",
"Name: 0, Length: 100, dtype: float64"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X[0]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pandas.core.series.Series"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(X[0])"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 17.930201\n",
"1 94.520592\n",
"2 320.259530\n",
"Name: 0, dtype: float64"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X.iloc[0]"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\litak\\Anaconda3\\envs\\tensorflow-cpu\\lib\\site-packages\\ipykernel_launcher.py:1: DeprecationWarning: \n",
".ix is deprecated. Please use\n",
".loc for label based indexing or\n",
".iloc for positional indexing\n",
"\n",
"See the documentation here:\n",
"http://pandas.pydata.org/pandas-docs/stable/indexing.html#ix-indexer-is-deprecated\n",
" \"\"\"Entry point for launching an IPython kernel.\n"
]
},
{
"data": {
"text/plain": [
"0 17.930201\n",
"1 94.520592\n",
"2 320.259530\n",
"Name: 0, dtype: float64"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X.ix[0]"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pandas.core.series.Series"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(X.iloc[0])"
]
},
{
"cell_type": "code",
"execution_count": 13,
"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>0</th>\n",
" <th>2</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>17.930201</td>\n",
" <td>320.259530</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>97.144697</td>\n",
" <td>404.634472</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>81.775901</td>\n",
" <td>181.485108</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>55.854342</td>\n",
" <td>321.773638</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>49.366550</td>\n",
" <td>322.465486</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>3.192702</td>\n",
" <td>94.618811</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>49.200784</td>\n",
" <td>356.348093</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>21.882804</td>\n",
" <td>181.653769</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>79.509863</td>\n",
" <td>423.557743</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>88.153887</td>\n",
" <td>369.229245</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>60.743854</td>\n",
" <td>427.605804</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>67.415582</td>\n",
" <td>292.471822</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>48.318116</td>\n",
" <td>395.529811</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>28.829972</td>\n",
" <td>319.031348</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>43.853743</td>\n",
" <td>287.428144</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>25.313694</td>\n",
" <td>292.768909</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>10.807727</td>\n",
" <td>159.663308</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>98.365746</td>\n",
" <td>438.798964</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>29.146910</td>\n",
" <td>250.986309</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>65.100302</td>\n",
" <td>231.711508</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>24.644113</td>\n",
" <td>163.398161</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>37.559805</td>\n",
" <td>83.480155</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>88.164506</td>\n",
" <td>466.265806</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>13.834621</td>\n",
" <td>100.886430</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>64.410844</td>\n",
" <td>365.641048</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>68.925992</td>\n",
" <td>426.140015</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>39.488442</td>\n",
" <td>235.532389</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>52.463178</td>\n",
" <td>283.291640</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>48.484787</td>\n",
" <td>298.581440</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>8.062088</td>\n",
" <td>309.234109</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>70</th>\n",
" <td>30.187692</td>\n",
" <td>89.539008</td>\n",
" </tr>\n",
" <tr>\n",
" <th>71</th>\n",
" <td>11.788418</td>\n",
" <td>181.550683</td>\n",
" </tr>\n",
" <tr>\n",
" <th>72</th>\n",
" <td>18.292424</td>\n",
" <td>224.773383</td>\n",
" </tr>\n",
" <tr>\n",
" <th>73</th>\n",
" <td>96.712668</td>\n",
" <td>219.567094</td>\n",
" </tr>\n",
" <tr>\n",
" <th>74</th>\n",
" <td>31.012739</td>\n",
" <td>298.490216</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75</th>\n",
" <td>11.397261</td>\n",
" <td>199.944045</td>\n",
" </tr>\n",
" <tr>\n",
" <th>76</th>\n",
" <td>17.392556</td>\n",
" <td>43.915692</td>\n",
" </tr>\n",
" <tr>\n",
" <th>77</th>\n",
" <td>72.182694</td>\n",
" <td>256.068378</td>\n",
" </tr>\n",
" <tr>\n",
" <th>78</th>\n",
" <td>73.980021</td>\n",
" <td>159.372581</td>\n",
" </tr>\n",
" <tr>\n",
" <th>79</th>\n",
" <td>94.493058</td>\n",
" <td>447.132704</td>\n",
" </tr>\n",
" <tr>\n",
" <th>80</th>\n",
" <td>84.562821</td>\n",
" <td>233.078830</td>\n",
" </tr>\n",
" <tr>\n",
" <th>81</th>\n",
" <td>51.742474</td>\n",
" <td>131.070180</td>\n",
" </tr>\n",
" <tr>\n",
" <th>82</th>\n",
" <td>53.748590</td>\n",
" <td>298.814333</td>\n",
" </tr>\n",
" <tr>\n",
" <th>83</th>\n",
" <td>85.050835</td>\n",
" <td>451.803523</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84</th>\n",
" <td>46.777250</td>\n",
" <td>368.366436</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85</th>\n",
" <td>49.758434</td>\n",
" <td>254.706774</td>\n",
" </tr>\n",
" <tr>\n",
" <th>86</th>\n",
" <td>24.119257</td>\n",
" <td>168.308433</td>\n",
" </tr>\n",
" <tr>\n",
" <th>87</th>\n",
" <td>27.201576</td>\n",
" <td>146.342260</td>\n",
" </tr>\n",
" <tr>\n",
" <th>88</th>\n",
" <td>7.009596</td>\n",
" <td>176.810149</td>\n",
" </tr>\n",
" <tr>\n",
" <th>89</th>\n",
" <td>97.646950</td>\n",
" <td>219.160280</td>\n",
" </tr>\n",
" <tr>\n",
" <th>90</th>\n",
" <td>1.382983</td>\n",
" <td>252.905653</td>\n",
" </tr>\n",
" <tr>\n",
" <th>91</th>\n",
" <td>22.323530</td>\n",
" <td>127.570479</td>\n",
" </tr>\n",
" <tr>\n",
" <th>92</th>\n",
" <td>45.045406</td>\n",
" <td>375.822340</td>\n",
" </tr>\n",
" <tr>\n",
" <th>93</th>\n",
" <td>40.163991</td>\n",
" <td>80.389019</td>\n",
" </tr>\n",
" <tr>\n",
" <th>94</th>\n",
" <td>53.182740</td>\n",
" <td>142.718183</td>\n",
" </tr>\n",
" <tr>\n",
" <th>95</th>\n",
" <td>46.456779</td>\n",
" <td>336.876154</td>\n",
" </tr>\n",
" <tr>\n",
" <th>96</th>\n",
" <td>77.130301</td>\n",
" <td>438.460586</td>\n",
" </tr>\n",
" <tr>\n",
" <th>97</th>\n",
" <td>68.600608</td>\n",
" <td>355.900287</td>\n",
" </tr>\n",
" <tr>\n",
" <th>98</th>\n",
" <td>41.693887</td>\n",
" <td>284.834637</td>\n",
" </tr>\n",
" <tr>\n",
" <th>99</th>\n",
" <td>4.142669</td>\n",
" <td>168.034401</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>100 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" 0 2\n",
"0 17.930201 320.259530\n",
"1 97.144697 404.634472\n",
"2 81.775901 181.485108\n",
"3 55.854342 321.773638\n",
"4 49.366550 322.465486\n",
"5 3.192702 94.618811\n",
"6 49.200784 356.348093\n",
"7 21.882804 181.653769\n",
"8 79.509863 423.557743\n",
"9 88.153887 369.229245\n",
"10 60.743854 427.605804\n",
"11 67.415582 292.471822\n",
"12 48.318116 395.529811\n",
"13 28.829972 319.031348\n",
"14 43.853743 287.428144\n",
"15 25.313694 292.768909\n",
"16 10.807727 159.663308\n",
"17 98.365746 438.798964\n",
"18 29.146910 250.986309\n",
"19 65.100302 231.711508\n",
"20 24.644113 163.398161\n",
"21 37.559805 83.480155\n",
"22 88.164506 466.265806\n",
"23 13.834621 100.886430\n",
"24 64.410844 365.641048\n",
"25 68.925992 426.140015\n",
"26 39.488442 235.532389\n",
"27 52.463178 283.291640\n",
"28 48.484787 298.581440\n",
"29 8.062088 309.234109\n",
".. ... ...\n",
"70 30.187692 89.539008\n",
"71 11.788418 181.550683\n",
"72 18.292424 224.773383\n",
"73 96.712668 219.567094\n",
"74 31.012739 298.490216\n",
"75 11.397261 199.944045\n",
"76 17.392556 43.915692\n",
"77 72.182694 256.068378\n",
"78 73.980021 159.372581\n",
"79 94.493058 447.132704\n",
"80 84.562821 233.078830\n",
"81 51.742474 131.070180\n",
"82 53.748590 298.814333\n",
"83 85.050835 451.803523\n",
"84 46.777250 368.366436\n",
"85 49.758434 254.706774\n",
"86 24.119257 168.308433\n",
"87 27.201576 146.342260\n",
"88 7.009596 176.810149\n",
"89 97.646950 219.160280\n",
"90 1.382983 252.905653\n",
"91 22.323530 127.570479\n",
"92 45.045406 375.822340\n",
"93 40.163991 80.389019\n",
"94 53.182740 142.718183\n",
"95 46.456779 336.876154\n",
"96 77.130301 438.460586\n",
"97 68.600608 355.900287\n",
"98 41.693887 284.834637\n",
"99 4.142669 168.034401\n",
"\n",
"[100 rows x 2 columns]"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X[[0, 2]]"
]
},
{
"cell_type": "code",
"execution_count": 17,
"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>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>3.192702</td>\n",
" <td>29.256299</td>\n",
" <td>94.618811</td>\n",
" </tr>\n",
" <tr>\n",
" <th>44</th>\n",
" <td>3.593966</td>\n",
" <td>96.252217</td>\n",
" <td>293.237183</td>\n",
" </tr>\n",
" <tr>\n",
" <th>54</th>\n",
" <td>4.593463</td>\n",
" <td>46.335932</td>\n",
" <td>145.818745</td>\n",
" </tr>\n",
" <tr>\n",
" <th>90</th>\n",
" <td>1.382983</td>\n",
" <td>84.944087</td>\n",
" <td>252.905653</td>\n",
" </tr>\n",
" <tr>\n",
" <th>99</th>\n",
" <td>4.142669</td>\n",
" <td>52.254726</td>\n",
" <td>168.034401</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 1 2\n",
"5 3.192702 29.256299 94.618811\n",
"44 3.593966 96.252217 293.237183\n",
"54 4.593463 46.335932 145.818745\n",
"90 1.382983 84.944087 252.905653\n",
"99 4.142669 52.254726 168.034401"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X[ X[0] < 5]"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 False\n",
"1 False\n",
"2 False\n",
"3 False\n",
"4 False\n",
"5 True\n",
"6 False\n",
"7 False\n",
"8 False\n",
"9 False\n",
"10 False\n",
"11 False\n",
"12 False\n",
"13 False\n",
"14 False\n",
"15 False\n",
"16 False\n",
"17 False\n",
"18 False\n",
"19 False\n",
"20 False\n",
"21 False\n",
"22 False\n",
"23 False\n",
"24 False\n",
"25 False\n",
"26 False\n",
"27 False\n",
"28 False\n",
"29 False\n",
" ... \n",
"70 False\n",
"71 False\n",
"72 False\n",
"73 False\n",
"74 False\n",
"75 False\n",
"76 False\n",
"77 False\n",
"78 False\n",
"79 False\n",
"80 False\n",
"81 False\n",
"82 False\n",
"83 False\n",
"84 False\n",
"85 False\n",
"86 False\n",
"87 False\n",
"88 False\n",
"89 False\n",
"90 True\n",
"91 False\n",
"92 False\n",
"93 False\n",
"94 False\n",
"95 False\n",
"96 False\n",
"97 False\n",
"98 False\n",
"99 True\n",
"Name: 0, Length: 100, dtype: bool"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X[0] < 5"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pandas.core.series.Series"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(X[0] < 5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.5.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Index(['Month', 'International airline passengers: monthly totals in thousands. Jan 49 ? Dec 60'], dtype='object')"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.read_csv(\"international-airline-passengers.csv\", engine=\"python\", skipfooter=3)\n",
"df.columns"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Index(['month', 'passengers'], dtype='object')"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.columns = [\"month\", \"passengers\"]\n",
"df.columns"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 112\n",
"1 118\n",
"2 132\n",
"3 129\n",
"4 121\n",
"5 135\n",
"6 148\n",
"7 148\n",
"8 136\n",
"9 119\n",
"10 104\n",
"11 118\n",
"12 115\n",
"13 126\n",
"14 141\n",
"15 135\n",
"16 125\n",
"17 149\n",
"18 170\n",
"19 170\n",
"20 158\n",
"21 133\n",
"22 114\n",
"23 140\n",
"24 145\n",
"25 150\n",
"26 178\n",
"27 163\n",
"28 172\n",
"29 178\n",
" ... \n",
"114 491\n",
"115 505\n",
"116 404\n",
"117 359\n",
"118 310\n",
"119 337\n",
"120 360\n",
"121 342\n",
"122 406\n",
"123 396\n",
"124 420\n",
"125 472\n",
"126 548\n",
"127 559\n",
"128 463\n",
"129 407\n",
"130 362\n",
"131 405\n",
"132 417\n",
"133 391\n",
"134 419\n",
"135 461\n",
"136 472\n",
"137 535\n",
"138 622\n",
"139 606\n",
"140 508\n",
"141 461\n",
"142 390\n",
"143 432\n",
"Name: passengers, Length: 144, dtype: int64"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['passengers']"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 112\n",
"1 118\n",
"2 132\n",
"3 129\n",
"4 121\n",
"5 135\n",
"6 148\n",
"7 148\n",
"8 136\n",
"9 119\n",
"10 104\n",
"11 118\n",
"12 115\n",
"13 126\n",
"14 141\n",
"15 135\n",
"16 125\n",
"17 149\n",
"18 170\n",
"19 170\n",
"20 158\n",
"21 133\n",
"22 114\n",
"23 140\n",
"24 145\n",
"25 150\n",
"26 178\n",
"27 163\n",
"28 172\n",
"29 178\n",
" ... \n",
"114 491\n",
"115 505\n",
"116 404\n",
"117 359\n",
"118 310\n",
"119 337\n",
"120 360\n",
"121 342\n",
"122 406\n",
"123 396\n",
"124 420\n",
"125 472\n",
"126 548\n",
"127 559\n",
"128 463\n",
"129 407\n",
"130 362\n",
"131 405\n",
"132 417\n",
"133 391\n",
"134 419\n",
"135 461\n",
"136 472\n",
"137 535\n",
"138 622\n",
"139 606\n",
"140 508\n",
"141 461\n",
"142 390\n",
"143 432\n",
"Name: passengers, Length: 144, dtype: int64"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.passengers"
]
},
{
"cell_type": "code",
"execution_count": 9,
"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>month</th>\n",
" <th>passengers</th>\n",
" <th>ones</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1949-01</td>\n",
" <td>112</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1949-02</td>\n",
" <td>118</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1949-03</td>\n",
" <td>132</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1949-04</td>\n",
" <td>129</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1949-05</td>\n",
" <td>121</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" month passengers ones\n",
"0 1949-01 112 1\n",
"1 1949-02 118 1\n",
"2 1949-03 132 1\n",
"3 1949-04 129 1\n",
"4 1949-05 121 1"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['ones'] = 1\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.5.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"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>Month</th>\n",
" <th>International airline passengers: monthly totals in thousands. Jan 49 ? Dec 60</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1949-01</td>\n",
" <td>112</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1949-02</td>\n",
" <td>118</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1949-03</td>\n",
" <td>132</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1949-04</td>\n",
" <td>129</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1949-05</td>\n",
" <td>121</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Month \\\n",
"0 1949-01 \n",
"1 1949-02 \n",
"2 1949-03 \n",
"3 1949-04 \n",
"4 1949-05 \n",
"\n",
" International airline passengers: monthly totals in thousands. Jan 49 ? Dec 60 \n",
"0 112 \n",
"1 118 \n",
"2 132 \n",
"3 129 \n",
"4 121 "
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.read_csv(\"international-airline-passengers.csv\", engine=\"python\", skipfooter=3)\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"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>month</th>\n",
" <th>passengers</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1949-01</td>\n",
" <td>112</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1949-02</td>\n",
" <td>118</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1949-03</td>\n",
" <td>132</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1949-04</td>\n",
" <td>129</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1949-05</td>\n",
" <td>121</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" month passengers\n",
"0 1949-01 112\n",
"1 1949-02 118\n",
"2 1949-03 132\n",
"3 1949-04 129\n",
"4 1949-05 121"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.columns = [\"month\", \"passengers\"]\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"def multiply_by_2(row):\n",
" return row[\"passengers\"] * 2"
]
},
{
"cell_type": "code",
"execution_count": 5,
"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>month</th>\n",
" <th>passengers</th>\n",
" <th>passengers_2</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1949-01</td>\n",
" <td>112</td>\n",
" <td>224</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1949-02</td>\n",
" <td>118</td>\n",
" <td>236</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1949-03</td>\n",
" <td>132</td>\n",
" <td>264</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1949-04</td>\n",
" <td>129</td>\n",
" <td>258</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1949-05</td>\n",
" <td>121</td>\n",
" <td>242</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" month passengers passengers_2\n",
"0 1949-01 112 224\n",
"1 1949-02 118 236\n",
"2 1949-03 132 264\n",
"3 1949-04 129 258\n",
"4 1949-05 121 242"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# with function\n",
"df['passengers_2'] = df.apply(multiply_by_2, axis=1)\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"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>month</th>\n",
" <th>passengers</th>\n",
" <th>passengers_2</th>\n",
" <th>passengers_3</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1949-01</td>\n",
" <td>112</td>\n",
" <td>224</td>\n",
" <td>336</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1949-02</td>\n",
" <td>118</td>\n",
" <td>236</td>\n",
" <td>354</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1949-03</td>\n",
" <td>132</td>\n",
" <td>264</td>\n",
" <td>396</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1949-04</td>\n",
" <td>129</td>\n",
" <td>258</td>\n",
" <td>387</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1949-05</td>\n",
" <td>121</td>\n",
" <td>242</td>\n",
" <td>363</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" month passengers passengers_2 passengers_3\n",
"0 1949-01 112 224 336\n",
"1 1949-02 118 236 354\n",
"2 1949-03 132 264 396\n",
"3 1949-04 129 258 387\n",
"4 1949-05 121 242 363"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# with lambda expression\n",
"df[\"passengers_3\"] = df.apply(lambda row: row[\"passengers\"] * 3, axis=1)\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"from datetime import datetime"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"datetime.datetime(1949, 1, 1, 0, 0)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# testing\n",
"datetime.strptime(\"1949-01\", \"%Y-%m\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"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>month</th>\n",
" <th>passengers</th>\n",
" <th>passengers_2</th>\n",
" <th>passengers_3</th>\n",
" <th>datetime_month</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1949-01</td>\n",
" <td>112</td>\n",
" <td>224</td>\n",
" <td>336</td>\n",
" <td>1949-01-01</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1949-02</td>\n",
" <td>118</td>\n",
" <td>236</td>\n",
" <td>354</td>\n",
" <td>1949-02-01</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1949-03</td>\n",
" <td>132</td>\n",
" <td>264</td>\n",
" <td>396</td>\n",
" <td>1949-03-01</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1949-04</td>\n",
" <td>129</td>\n",
" <td>258</td>\n",
" <td>387</td>\n",
" <td>1949-04-01</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1949-05</td>\n",
" <td>121</td>\n",
" <td>242</td>\n",
" <td>363</td>\n",
" <td>1949-05-01</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" month passengers passengers_2 passengers_3 datetime_month\n",
"0 1949-01 112 224 336 1949-01-01\n",
"1 1949-02 118 236 354 1949-02-01\n",
"2 1949-03 132 264 396 1949-03-01\n",
"3 1949-04 129 258 387 1949-04-01\n",
"4 1949-05 121 242 363 1949-05-01"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['datetime_month'] = df.apply(lambda row: datetime.strptime(row['month'], \"%Y-%m\"), axis=1)\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 144 entries, 0 to 143\n",
"Data columns (total 5 columns):\n",
"month 144 non-null object\n",
"passengers 144 non-null int64\n",
"passengers_2 144 non-null int64\n",
"passengers_3 144 non-null int64\n",
"datetime_month 144 non-null datetime64[ns]\n",
"dtypes: datetime64[ns](1), int64(3), object(1)\n",
"memory usage: 5.7+ KB\n"
]
}
],
"source": [
"df.info()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.5.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 7,
"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>user_id</th>\n",
" <th>email</th>\n",
" <th>age</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>alice@gmail.com</td>\n",
" <td>20</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>bob@gmail.com</td>\n",
" <td>25</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>carol@gmail.com</td>\n",
" <td>30</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" user_id email age\n",
"0 1 alice@gmail.com 20\n",
"1 2 bob@gmail.com 25\n",
"2 3 carol@gmail.com 30"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t1 = pd.read_csv(\"table1.csv\")\n",
"t1"
]
},
{
"cell_type": "code",
"execution_count": 8,
"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>user_id</th>\n",
" <th>ad_id</th>\n",
" <th>click</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2</td>\n",
" <td>4</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>3</td>\n",
" <td>5</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" user_id ad_id click\n",
"0 1 1 1\n",
"1 1 2 0\n",
"2 1 5 0\n",
"3 2 3 0\n",
"4 2 4 1\n",
"5 2 1 0\n",
"6 3 2 0\n",
"7 3 1 0\n",
"8 3 3 0\n",
"9 3 4 0\n",
"10 3 5 1"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t2 = pd.read_csv(\"table2.csv\")\n",
"t2"
]
},
{
"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>user_id</th>\n",
" <th>email</th>\n",
" <th>age</th>\n",
" <th>ad_id</th>\n",
" <th>click</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>alice@gmail.com</td>\n",
" <td>20</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>alice@gmail.com</td>\n",
" <td>20</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1</td>\n",
" <td>alice@gmail.com</td>\n",
" <td>20</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2</td>\n",
" <td>bob@gmail.com</td>\n",
" <td>25</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2</td>\n",
" <td>bob@gmail.com</td>\n",
" <td>25</td>\n",
" <td>4</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>2</td>\n",
" <td>bob@gmail.com</td>\n",
" <td>25</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>3</td>\n",
" <td>carol@gmail.com</td>\n",
" <td>30</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>3</td>\n",
" <td>carol@gmail.com</td>\n",
" <td>30</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>3</td>\n",
" <td>carol@gmail.com</td>\n",
" <td>30</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>3</td>\n",
" <td>carol@gmail.com</td>\n",
" <td>30</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>3</td>\n",
" <td>carol@gmail.com</td>\n",
" <td>30</td>\n",
" <td>5</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" user_id email age ad_id click\n",
"0 1 alice@gmail.com 20 1 1\n",
"1 1 alice@gmail.com 20 2 0\n",
"2 1 alice@gmail.com 20 5 0\n",
"3 2 bob@gmail.com 25 3 0\n",
"4 2 bob@gmail.com 25 4 1\n",
"5 2 bob@gmail.com 25 1 0\n",
"6 3 carol@gmail.com 30 2 0\n",
"7 3 carol@gmail.com 30 1 0\n",
"8 3 carol@gmail.com 30 3 0\n",
"9 3 carol@gmail.com 30 4 0\n",
"10 3 carol@gmail.com 30 5 1"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"m = pd.merge(t1, t2, on='user_id')\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": 9,
"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>user_id</th>\n",
" <th>email</th>\n",
" <th>age</th>\n",
" <th>ad_id</th>\n",
" <th>click</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>alice@gmail.com</td>\n",
" <td>20</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>alice@gmail.com</td>\n",
" <td>20</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1</td>\n",
" <td>alice@gmail.com</td>\n",
" <td>20</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2</td>\n",
" <td>bob@gmail.com</td>\n",
" <td>25</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2</td>\n",
" <td>bob@gmail.com</td>\n",
" <td>25</td>\n",
" <td>4</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>2</td>\n",
" <td>bob@gmail.com</td>\n",
" <td>25</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>3</td>\n",
" <td>carol@gmail.com</td>\n",
" <td>30</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>3</td>\n",
" <td>carol@gmail.com</td>\n",
" <td>30</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>3</td>\n",
" <td>carol@gmail.com</td>\n",
" <td>30</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>3</td>\n",
" <td>carol@gmail.com</td>\n",
" <td>30</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>3</td>\n",
" <td>carol@gmail.com</td>\n",
" <td>30</td>\n",
" <td>5</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" user_id email age ad_id click\n",
"0 1 alice@gmail.com 20 1 1\n",
"1 1 alice@gmail.com 20 2 0\n",
"2 1 alice@gmail.com 20 5 0\n",
"3 2 bob@gmail.com 25 3 0\n",
"4 2 bob@gmail.com 25 4 1\n",
"5 2 bob@gmail.com 25 1 0\n",
"6 3 carol@gmail.com 30 2 0\n",
"7 3 carol@gmail.com 30 1 0\n",
"8 3 carol@gmail.com 30 3 0\n",
"9 3 carol@gmail.com 30 4 0\n",
"10 3 carol@gmail.com 30 5 1"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# or\n",
"t1.merge(t2, on='user_id')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.5.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
17.9302012052,94.5205919533,320.259529602
97.1446971852,69.5932819844,404.634471526
81.7759007845,5.73764809688,181.485107741
55.8543424175,70.3259016768,321.773638018
49.3665499855,75.1140401571,322.465485583
3.19270246506,29.2562988631,94.6188108954
49.2007840582,86.1444385075,356.348092747
21.882803904,46.8415051959,181.653769226
79.5098627219,87.397355535,423.557743194
88.1538874975,65.2056419279,369.229245443
60.7438543399,99.9576339008,427.605803661
67.4155819451,50.3683096094,292.471821553
48.3181157719,99.1289531425,395.529811407
28.8299719729,87.1849488537,319.031348455
43.853742664,64.4736390798,287.4281441
25.3136940868,83.5452942552,292.768908839
10.807726675,45.6955685904,159.663307674
98.365745882,82.6973935253,438.798963866
29.1469099692,66.3651067611,250.986309034
65.1003018959,33.3538834975,231.711507921
24.6441134909,39.5400527406,163.398160832
37.5598048804,1.34572784158,83.4801551365
88.1645062351,95.1536625708,466.265805791
13.8346208354,25.494048204,100.886430268
64.4108437467,77.2598381277,365.641048062
68.925991798,97.4536007955,426.140015493
39.4884422375,50.8561281903,235.532389457
52.4631776831,59.7765096878,283.291640318
48.4847869797,66.9703542227,298.581440375
8.06208781377,98.2426001448,309.234108782
32.7318877149,18.8535355289,129.610139015
11.6523787962,66.2645117418,224.150542091
13.7303535349,70.4725091314,235.305665631
8.18555176536,41.8519894198,153.484189455
53.6098761481,94.560121637,394.939444253
95.3686098922,47.2955069599,336.126738879
87.3336092062,93.8039343271,449.363351987
66.3576110919,81.8475512843,387.014816485
19.7547175302,65.5233009197,240.389441595
21.1334404504,47.4371819938,177.14828058
22.37386481,25.9556275364,119.61125795
93.9904040537,0.127890520058,196.716166657
86.7201980995,18.413766785,236.260808358
98.9983729904,60.2312656882,384.381344695
3.59396564372,96.2522173231,293.237183045
15.1023633732,92.5569035696,304.890882807
97.8341407695,2.02390810433,201.293598424
19.9382196923,46.7782734632,170.610093035
30.3735111369,58.7775251616,242.373484227
73.2928831485,67.6696277593,353.082991304
52.2309008804,81.9024482531,348.725688557
86.4295761137,66.5402275975,365.959970954
93.4008021441,18.0752459352,235.472381633
13.213460059,91.4888587787,300.606878255
4.59346270394,46.3359315158,145.818745251
15.6692915825,35.5437439971,138.880334695
52.9593597724,68.7202096086,317.163707741
56.8175212312,47.5727319202,254.903631301
51.1335430813,78.0421674552,334.5843335
7.86216471526,17.7290817759,69.3555888141
54.6986037014,92.7445841407,386.859937239
86.3990630133,41.8886945857,294.871713576
11.9475060186,42.9613867358,156.754219545
70.3584010648,83.7062345104,391.806135291
29.0223663255,84.327783082,319.310462851
42.7594799067,97.4933260814,376.291589478
96.2156564389,25.8342825832,280.617043873
53.2277276552,27.9055085669,194.430465068
30.3609896715,0.939644215313,69.6488631767
83.2775653897,73.1793485695,384.597184993
30.1876924786,7.1465385989,89.5390083986
11.7884184617,51.6977608445,181.550682802
18.2924240117,61.9779760484,224.773382884
96.7126676927,9.0291015125,219.567093701
31.0127386947,78.2833824603,298.490216481
11.3972607536,61.728693243,199.944044715
17.3925557906,4.24114086314,43.9156923531
72.1826937267,34.5390721676,256.068378234
73.980020785,3.71649343826,159.372580639
94.4930583509,88.41719702,447.132703621
84.5628207335,20.2411621935,233.078829579
51.7424739723,11.009747964,131.070179635
53.7485903953,60.0251022958,298.814332704
85.0508347563,95.7369969538,451.80352299
46.7772504514,90.2022062395,368.366435952
49.7584341737,52.834494361,254.706774007
24.1192565017,42.1028107802,168.308432759
27.2015764537,29.9787492892,146.34226
7.00959616769,55.876058392,176.810148976
97.6469496688,8.14762512696,219.16028041
1.38298250945,84.9440869198,252.905652954
22.3235303534,27.5150750402,127.570478844
45.0454062325,93.5204022248,375.822340339
40.1639914677,0.161699234822,80.3890193252
53.182739793,8.17031616228,142.718183077
46.4567791559,82.000170914,336.876154384
77.1303006946,95.1887594549,438.460586127
68.600607572,72.5711807231,355.900286918
41.6938871165,69.241125973,284.834636711
4.1426693978,52.2547263792,168.034400947
"Month","International airline passengers: monthly totals in thousands. Jan 49 ? Dec 60"
"1949-01",112
"1949-02",118
"1949-03",132
"1949-04",129
"1949-05",121
"1949-06",135
"1949-07",148
"1949-08",148
"1949-09",136
"1949-10",119
"1949-11",104
"1949-12",118
"1950-01",115
"1950-02",126
"1950-03",141
"1950-04",135
"1950-05",125
"1950-06",149
"1950-07",170
"1950-08",170
"1950-09",158
"1950-10",133
"1950-11",114
"1950-12",140
"1951-01",145
"1951-02",150
"1951-03",178
"1951-04",163
"1951-05",172
"1951-06",178
"1951-07",199
"1951-08",199
"1951-09",184
"1951-10",162
"1951-11",146
"1951-12",166
"1952-01",171
"1952-02",180
"1952-03",193
"1952-04",181
"1952-05",183
"1952-06",218
"1952-07",230
"1952-08",242
"1952-09",209
"1952-10",191
"1952-11",172
"1952-12",194
"1953-01",196
"1953-02",196
"1953-03",236
"1953-04",235
"1953-05",229
"1953-06",243
"1953-07",264
"1953-08",272
"1953-09",237
"1953-10",211
"1953-11",180
"1953-12",201
"1954-01",204
"1954-02",188
"1954-03",235
"1954-04",227
"1954-05",234
"1954-06",264
"1954-07",302
"1954-08",293
"1954-09",259
"1954-10",229
"1954-11",203
"1954-12",229
"1955-01",242
"1955-02",233
"1955-03",267
"1955-04",269
"1955-05",270
"1955-06",315
"1955-07",364
"1955-08",347
"1955-09",312
"1955-10",274
"1955-11",237
"1955-12",278
"1956-01",284
"1956-02",277
"1956-03",317
"1956-04",313
"1956-05",318
"1956-06",374
"1956-07",413
"1956-08",405
"1956-09",355
"1956-10",306
"1956-11",271
"1956-12",306
"1957-01",315
"1957-02",301
"1957-03",356
"1957-04",348
"1957-05",355
"1957-06",422
"1957-07",465
"1957-08",467
"1957-09",404
"1957-10",347
"1957-11",305
"1957-12",336
"1958-01",340
"1958-02",318
"1958-03",362
"1958-04",348
"1958-05",363
"1958-06",435
"1958-07",491
"1958-08",505
"1958-09",404
"1958-10",359
"1958-11",310
"1958-12",337
"1959-01",360
"1959-02",342
"1959-03",406
"1959-04",396
"1959-05",420
"1959-06",472
"1959-07",548
"1959-08",559
"1959-09",463
"1959-10",407
"1959-11",362
"1959-12",405
"1960-01",417
"1960-02",391
"1960-03",419
"1960-04",461
"1960-05",472
"1960-06",535
"1960-07",622
"1960-08",606
"1960-09",508
"1960-10",461
"1960-11",390
"1960-12",432
International airline passengers: monthly totals in thousands. Jan 49 ? Dec 60
user_id,email,age
1,alice@gmail.com,20
2,bob@gmail.com,25
3,carol@gmail.com,30
\ No newline at end of file
user_id,ad_id,click
1,1,1
1,2,0
1,5,0
2,3,0
2,4,1
2,1,0
3,2,0
3,1,0
3,3,0
3,4,0
3,5,1
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment