Skip to content

Instantly share code, notes, and snippets.

@rschutjens
Created March 23, 2016 23:31
Show Gist options
  • Save rschutjens/35d269ceade088c52fff to your computer and use it in GitHub Desktop.
Save rschutjens/35d269ceade088c52fff to your computer and use it in GitHub Desktop.
Udacity: Descriptive Statistics Project
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from IPython.display import IFrame\n",
"import pandas as pd\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"import warnings\n",
"warnings.filterwarnings('ignore') # to hide an ugly warning doing the boxplot"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"link_ss = 'https://docs.google.com/spreadsheets/d/1OVyFiyJlpSpTJUlB65t5WEfJlDB1bp2NqtTS0YYzYNM/'\n",
"\n",
"download_link = 'https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=1OVyFiyJlpSpTJUlB65t5WEfJlDB1bp2NqtTS0YYzYNM&exportFormat=xlsx'\n",
"\n",
"table = pd.read_excel(download_link, sheetname = 'samples of 3 cards', header = 0,\n",
" parse_cols = 'A, B, C, D, E, F, G, H, I',\n",
" convert_floats = True)\n",
"\n",
"def print_sheet(sslink, sheet, cellrange, width, height):\n",
" # prints the table on sheet, with cellrange\n",
" link = sslink + 'pubhtml?&single=true&gid=' + sheet + '&range=' + cellrange + '&widget=false&chrome=false'\n",
" return IFrame(link, width = width, height = height)\n",
"\n",
"def print_chart(sslink, chart, width, height):\n",
" # prints chart from spreadsheet \n",
" link = sslink + 'pubchart?oid=' + chart + '&format=interactive'\n",
" return IFrame(link, width = width, height = height)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Descriptive Statistics\n",
"\n",
"As an exercise we draw sets of 3 cards from a deck (every time a set is drawn, the cards are shuffled back into the deck). We sum up the cards using the following rules: an Ace has a value of 1, numbered cards have their number as value, pictured cards have a value of 10.\n",
"\n",
"This projects shows the use of descriptive statistics, using histograms, taking samples, and making estimates based on the sampling distribution, to investigate the above experiment. I've use google spreadsheets for this product. If you want to view or download the spreadsheet, go [here](https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=1OVyFiyJlpSpTJUlB65t5WEfJlDB1bp2NqtTS0YYzYNM&exportFormat=xlsx).\n",
"\n",
"\n",
"To start of I made a list of all cards in a deck, with no jokers, the deck has 52 cards. Using the frequency function you can reduce the total deck (total population) to the table below. As every numbered card is in the deck once suit, they have a frequency of 4. But because all numbered cards count as 10 points, as well as the number 10 cards themselves, the card value of 10 has a frequency of 16. You can easily check this with the description in the first paragraph."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"250\"\n",
" src=\"https://docs.google.com/spreadsheets/d/1OVyFiyJlpSpTJUlB65t5WEfJlDB1bp2NqtTS0YYzYNM/pubhtml?&single=true&gid=0&range=c1:e11&widget=false&chrome=false\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7409090>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print_sheet(link_ss, '0', 'c1:e11', '100%', 250)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"75\"\n",
" src=\"https://docs.google.com/spreadsheets/d/1OVyFiyJlpSpTJUlB65t5WEfJlDB1bp2NqtTS0YYzYNM/pubhtml?&single=true&gid=0&range=g1:i2&widget=false&chrome=false\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x74091b0>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print_sheet(link_ss, '0', 'g1:i2', '100%', 75)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"From the table it is straight forward to calculate the average and standard deviation of the card values, they are given in the table above. From the freqeuncy table, the relative frequency is calculated by deviding by the total amount of cards, 52, this results in the histogram:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"400\"\n",
" src=\"https://docs.google.com/spreadsheets/d/1OVyFiyJlpSpTJUlB65t5WEfJlDB1bp2NqtTS0YYzYNM/pubchart?oid=667448274&format=interactive\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x74091d0>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print_chart(link_ss, '667448274', '100%', 400)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When we draw one card from the deck, the above histogram gives the probability distribution for the card value.\n",
"\n",
"## Drawing cards"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now that the population statistics are known, I sampled the deck by using the website [random.org](https://www.random.org/playing-cards/). In total I sampled the deck 60 times, each time drawing 3 cards without replacement. Afterward the total sum of the cards is calculated by adding up their value. If you are interested in the total sample, check the speadsheet, or scroll down below.\n",
"\n",
"Below the histogram of these 60 samples is given. As can be seen from the graph the sampling of sum of 3 cards is approximately normally distributed."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"375\"\n",
" src=\"https://docs.google.com/spreadsheets/d/1OVyFiyJlpSpTJUlB65t5WEfJlDB1bp2NqtTS0YYzYNM/pubchart?oid=313708577&format=interactive\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7409130>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print_chart(link_ss, '313708577', '100%', 375)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"75\"\n",
" src=\"https://docs.google.com/spreadsheets/d/1OVyFiyJlpSpTJUlB65t5WEfJlDB1bp2NqtTS0YYzYNM/pubhtml?&single=true&gid=869336022&range=n1:p2&widget=false&chrome=false\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7409250>"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print_sheet(link_ss, '869336022', 'n1:p2', '100%', 75)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"From the sample a few measures of center can be calculated, the mean is 20.35, the mode is 24, and the median is 21. Different measures of spread are given below, standard deviation, quartiles, minimum, maximum and IQR. The last 5 are combined into the boxplot below. For details about the calculations you can check the spreadsheet for the functions. Next will be a discussion on what we expect our distribution to look like depending on the population distribution."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"75\"\n",
" src=\"https://docs.google.com/spreadsheets/d/1OVyFiyJlpSpTJUlB65t5WEfJlDB1bp2NqtTS0YYzYNM/pubhtml?&single=true&gid=869336022&range=m5:r6&widget=false&chrome=false\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7409330>"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print_sheet(link_ss, '869336022', 'm5:r6', '100%', 75)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.text.Text at 0x765d210>"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEACAYAAACwB81wAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAE41JREFUeJzt3X2wbXdd3/H3J1wEAyb38pCESs2JlkHDEE54kmmonABC\nOvKMhhkevBccSu0ItXQYKepcKHYwaNGi7VgxzUla0AQdCEGQBMgWQUAkuRBspK0SHJjkRvJEiICE\n++0fe93k5Oace/de56z9sNb7NbPnrrX2Xmt9187J9/zOd//Wd6eqkCT133HzDkCSNBsmfEkaCBO+\nJA2ECV+SBsKEL0kDYcKXpIHoNOEnuV+STye5Osk1SfY32/ckuTzJF5N8KMmJXcYhSYJ0PQ8/yfFV\n9Q9J7gN8AngN8ELgpqp6a5JfAPZU1es7DUSSBq7zkk5V/UOzeD9gF1DAc4ELm+0XAs/rOg5JGrrO\nE36S45JcDdwAXFFVnwFOrqqDAFV1A3BS13FI0tDNYoR/qKrOBB4OPDHJoxiP8u/xsq7jkKSh2zWr\nE1XV15OMgHOAg0lOrqqDSU4BbtxsnyT+IpCkFqoqR27rNOEneQjwnaq6Lcn3Aj8O/CrwPmAfcB6w\nF7h0q2PY3E2LKHkjVW+cdxjSppJ75Xqg+xH+w4ALkxzHuHx0cVV9IMmngEuSvAL4MnBux3FIO+y6\neQcgTa3ThF9V1wCP3WT7zcDTuzy3JOmevNNWamXfvAOQpmbCl1rYv39t3iFIUzPhSy2srY3mHYI0\nNRO+JA1E5710tiNJLXJ8krSIkmw6D98RviQNhAlfamE0Gs07BGlqJnyphfX1eUcgTc8avtRCAv5o\nalFZw5ekgTPhS62M5h2ANDUTviQNhDV8qQVr+Fpk1vClHbR//7wjkKZnwpdasJeOlpEJX5IGwhq+\nJPWMNXxJGjgTvtSCvXS0jEz4Ug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jm\n+WnNCP3zwNnAozbZd6v35xnA65NcDYyA7wF+APgk8ItJXgesVNW3t9hfPWfC19xU1f8FHss4Wf9K\nkl9qnrqTu38273/Ebt9u9i3gOxu2H2LnphlvllDfDHy0qh4NPPuIuO5ocY5LgBc1paFDVfU3Se4H\n/FfGfy2cAfwe975+2Pr9CfDC5i+mM6vqtKr6YlX9fhPzt4APJFlrEa96wISvuUnyMOCbVfUu4NcY\nJ3+ALwGPa5ZfeLRDHO34VfV14JYkZzWbXgb86THC+hTwLw6XW5LsabafAHy1WX75Ufb/GONEflxz\nfWdvEdvfAt8Ffpm7R/f3Z1yeuSnJA4Gf3OIcW70/HwJec3glyWrz72lV9aWq+i3gUuCMo8SvHptn\nLx3p0cCvJTkE/CPws832/wicn+Q2xqWJrUxyE8le4L83tey/5ejJmqr6WpJ/xfjGwAA3As9k/Avp\nwuavkD8+yv7vSfJU4K+AvwP+/Cinuxh4K/BLzb63JXlHs+/1wMbvidh4rVu9P28GfrMpBx3XXO9z\ngHOTvIzxX0TXA//paO+B+ssbryRpICzpSNJAmPAlaSBM+JI0ECZ8SRoIE74kDYQJX5IGwoQvSQNh\nwpekgfj/h5JJSVyulWMAAAAASUVORK5CYII=\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x74093d0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"table.boxplot(column = 'sum of card values');\n",
"plt.ylabel('value of sum')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As our samples are taken without replacement, the drawing of cards in one set of 3 is not independent. This has some influence on the standard deviation, a summary of it can be seen [here](https://www.ma.utexas.edu/users/parker/sampling/woreplshort.htm). The different samples are independent as we reshuffle the cards back in the deck and draw 3 new parts. A small correction to the standard deviation is expected by the first observation. \n",
"\n",
"Secondly we are using the sum of values, not the mean, i.e. it is a sampling distribution of the sum (not the mean). It is easy to [show](http://pages.uoregon.edu/aarong/teaching/G4074_Outline/node19.html) that the average of this distribution is $n = 3$ times the population mean $\\mu = 6.54$, so that we expect a mean of $19.62$. Compared to 20.35, the average of the 60 samples (especially since the standard deviation is 5, our estimate makes sense).\n",
"\n",
"For the expected standard deviation the methods of both references above can be combined into the following formula:\n",
"$$ s = \\sqrt{n}\\sigma\\sqrt{1 - \\frac{n - 1}{N - 1}}$$\n",
"Where $N = 52$ is the number of cards in the deck, and $\\sigma = 3.15$ is the standard deviation of the population."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"std with correction: 5.34791053205 , std of sum of independent random sample: 5.45596004384\n"
]
}
],
"source": [
"std = lambda n, N, sigma: np.sqrt(n)*sigma*np.sqrt(1 - (n - 1.0) / (N - 1.0))\n",
"print 'std with correction:', std(3, 52, 3.15), ', std of sum of independent random sample:', np.sqrt(3)*3.15"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Above, the expected values are calculated for the standard deviation corrected for sampling without replacement. From our sample a value of 5.06 should be compared to these values. For better estimates we should take more samples from the deck to calculate the distribution and its properties.\n",
"\n",
"The sampling distribution of means has an standard deviation that scales with $1 / \\sqrt{n}$, it's average is thesame as the population average. You can intuitively see that the standard deviation of the sampling distribution of sums scales with $\\sqrt{n}$ by comparing the two cases. The average of the sum scales with a factor $n$ as mentioned before, as we are basically doing the same thing as the sampling distribution of means, except devide by the factor $n$ to take the average.\n",
"\n",
"The same factor scales the standard deviation of the sampling distribution of sums ([see identities and mathematical properties](https://en.wikipedia.org/wiki/Standard_deviation)), compared to the one for means. One factor of $\\sqrt{n}$ cancels, resulting in the factor $\\sqrt{n}$ in the numerator in the equation above."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### predictions\n",
"To make predictions based on our sampling experiment, we assume the distribution is approximately normal (as can be seen from the histogram), and can approximate it with a continuous normal distribution with mean of 20.35 and standard deviation 5.06. With the help of the z-table predictions can now be made.\n",
"\n",
"For example, we expect that 90% of the sums of 3 cards will fall between 12 and 29. Below you can see the z-values for 90% CI around the mean (see spreadsheet for detailed functions)."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"75\"\n",
" src=\"https://docs.google.com/spreadsheets/d/1OVyFiyJlpSpTJUlB65t5WEfJlDB1bp2NqtTS0YYzYNM/pubhtml?&single=true&gid=869336022&range=l25:n27&widget=false&chrome=false\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x74093f0>"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print_sheet(link_ss, '869336022', 'l25:n27', '100%', 75)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also calculate with what probability we expect a sum of 20 or higher. Calculate the z value for a sum of 20 by standardizing it, then Looking up the z-value in the table, gives a percentile of 47.21% for the value of 20. And thus we expect to get a value of 20 or higher with a chance of 52.79%."
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"75\"\n",
" src=\"https://docs.google.com/spreadsheets/d/1OVyFiyJlpSpTJUlB65t5WEfJlDB1bp2NqtTS0YYzYNM/pubhtml?&single=true&gid=869336022&range=l29:p30&widget=false&chrome=false\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x74098d0>"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print_sheet(link_ss, '869336022', 'l29:p30', '100%', 75)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 60 samples table"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"1300\"\n",
" src=\"https://docs.google.com/spreadsheets/d/1OVyFiyJlpSpTJUlB65t5WEfJlDB1bp2NqtTS0YYzYNM/pubhtml?&single=true&gid=869336022&range=a1:i61&widget=false&chrome=false\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7409350>"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# table of samples\n",
"print_sheet(link_ss, '869336022', 'a1:i61', '100%', 1300)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>card 1 name</th>\n",
" <th>card 1 value</th>\n",
" <th>card 2 name</th>\n",
" <th>card 2 value</th>\n",
" <th>card 3 name</th>\n",
" <th>card 3 value</th>\n",
" <th>sum of card values</th>\n",
" <th>deviation from mean sum</th>\n",
" <th>squared deviations</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>clover king</td>\n",
" <td>10</td>\n",
" <td>spades 10</td>\n",
" <td>10</td>\n",
" <td>spades 2</td>\n",
" <td>2</td>\n",
" <td>22</td>\n",
" <td>1.65</td>\n",
" <td>2.7225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>spades 4</td>\n",
" <td>4</td>\n",
" <td>hearts 4</td>\n",
" <td>4</td>\n",
" <td>hearts 10</td>\n",
" <td>10</td>\n",
" <td>18</td>\n",
" <td>-2.35</td>\n",
" <td>5.5225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>clover 2</td>\n",
" <td>2</td>\n",
" <td>diamond 9</td>\n",
" <td>9</td>\n",
" <td>spades 7</td>\n",
" <td>7</td>\n",
" <td>18</td>\n",
" <td>-2.35</td>\n",
" <td>5.5225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>diamond queen</td>\n",
" <td>10</td>\n",
" <td>hearts 10</td>\n",
" <td>10</td>\n",
" <td>diamond 6</td>\n",
" <td>6</td>\n",
" <td>26</td>\n",
" <td>5.65</td>\n",
" <td>31.9225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>spades 9</td>\n",
" <td>9</td>\n",
" <td>clover 7</td>\n",
" <td>7</td>\n",
" <td>spades ace</td>\n",
" <td>1</td>\n",
" <td>17</td>\n",
" <td>-3.35</td>\n",
" <td>11.2225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>clover king</td>\n",
" <td>10</td>\n",
" <td>clover 2</td>\n",
" <td>2</td>\n",
" <td>clover 6</td>\n",
" <td>6</td>\n",
" <td>18</td>\n",
" <td>-2.35</td>\n",
" <td>5.5225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>hearts 4</td>\n",
" <td>4</td>\n",
" <td>hearts king</td>\n",
" <td>10</td>\n",
" <td>clover 5</td>\n",
" <td>5</td>\n",
" <td>19</td>\n",
" <td>-1.35</td>\n",
" <td>1.8225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>hearts bishop</td>\n",
" <td>10</td>\n",
" <td>hearts queen</td>\n",
" <td>10</td>\n",
" <td>spades 4</td>\n",
" <td>4</td>\n",
" <td>24</td>\n",
" <td>3.65</td>\n",
" <td>13.3225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>clover king</td>\n",
" <td>10</td>\n",
" <td>diamond 3</td>\n",
" <td>3</td>\n",
" <td>heart bishop</td>\n",
" <td>10</td>\n",
" <td>23</td>\n",
" <td>2.65</td>\n",
" <td>7.0225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>clover ace</td>\n",
" <td>1</td>\n",
" <td>hearts 5</td>\n",
" <td>5</td>\n",
" <td>clover 7</td>\n",
" <td>7</td>\n",
" <td>13</td>\n",
" <td>-7.35</td>\n",
" <td>54.0225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>hearts king</td>\n",
" <td>10</td>\n",
" <td>bishop 10</td>\n",
" <td>10</td>\n",
" <td>hearts ace</td>\n",
" <td>1</td>\n",
" <td>21</td>\n",
" <td>0.65</td>\n",
" <td>0.4225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>hears bishop</td>\n",
" <td>10</td>\n",
" <td>clover king</td>\n",
" <td>10</td>\n",
" <td>hearts 5</td>\n",
" <td>5</td>\n",
" <td>25</td>\n",
" <td>4.65</td>\n",
" <td>21.6225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>clover 5</td>\n",
" <td>5</td>\n",
" <td>clover 6</td>\n",
" <td>6</td>\n",
" <td>hearts ace</td>\n",
" <td>1</td>\n",
" <td>12</td>\n",
" <td>-8.35</td>\n",
" <td>69.7225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>diamond ace</td>\n",
" <td>1</td>\n",
" <td>diamond bishop</td>\n",
" <td>10</td>\n",
" <td>diamond 5</td>\n",
" <td>5</td>\n",
" <td>16</td>\n",
" <td>-4.35</td>\n",
" <td>18.9225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>diamond 5</td>\n",
" <td>5</td>\n",
" <td>diamond bishop</td>\n",
" <td>10</td>\n",
" <td>clover 9</td>\n",
" <td>9</td>\n",
" <td>24</td>\n",
" <td>3.65</td>\n",
" <td>13.3225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>hearts ace</td>\n",
" <td>1</td>\n",
" <td>hearts 8</td>\n",
" <td>8</td>\n",
" <td>clover king</td>\n",
" <td>10</td>\n",
" <td>19</td>\n",
" <td>-1.35</td>\n",
" <td>1.8225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>diamond 7</td>\n",
" <td>7</td>\n",
" <td>clover 9</td>\n",
" <td>9</td>\n",
" <td>clover 8</td>\n",
" <td>8</td>\n",
" <td>24</td>\n",
" <td>3.65</td>\n",
" <td>13.3225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>hearts king</td>\n",
" <td>10</td>\n",
" <td>diamond 7</td>\n",
" <td>7</td>\n",
" <td>hearts 5</td>\n",
" <td>5</td>\n",
" <td>22</td>\n",
" <td>1.65</td>\n",
" <td>2.7225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>hearts 3</td>\n",
" <td>3</td>\n",
" <td>spades bishop</td>\n",
" <td>10</td>\n",
" <td>clover 6</td>\n",
" <td>6</td>\n",
" <td>19</td>\n",
" <td>-1.35</td>\n",
" <td>1.8225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>diamond bishop</td>\n",
" <td>10</td>\n",
" <td>diamond 2</td>\n",
" <td>2</td>\n",
" <td>clover 2</td>\n",
" <td>2</td>\n",
" <td>14</td>\n",
" <td>-6.35</td>\n",
" <td>40.3225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>diamond 4</td>\n",
" <td>4</td>\n",
" <td>clover 9</td>\n",
" <td>9</td>\n",
" <td>diamond 2</td>\n",
" <td>2</td>\n",
" <td>15</td>\n",
" <td>-5.35</td>\n",
" <td>28.6225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>hearts 3</td>\n",
" <td>3</td>\n",
" <td>diamond 5</td>\n",
" <td>5</td>\n",
" <td>diamond 3</td>\n",
" <td>3</td>\n",
" <td>11</td>\n",
" <td>-9.35</td>\n",
" <td>87.4225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>hearts 4</td>\n",
" <td>4</td>\n",
" <td>clover 9</td>\n",
" <td>9</td>\n",
" <td>hearts 2</td>\n",
" <td>2</td>\n",
" <td>15</td>\n",
" <td>-5.35</td>\n",
" <td>28.6225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>spades 2</td>\n",
" <td>2</td>\n",
" <td>diamond 3</td>\n",
" <td>3</td>\n",
" <td>spades 9</td>\n",
" <td>9</td>\n",
" <td>14</td>\n",
" <td>-6.35</td>\n",
" <td>40.3225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>spades bishop</td>\n",
" <td>10</td>\n",
" <td>hearts bishop</td>\n",
" <td>10</td>\n",
" <td>bishop 3</td>\n",
" <td>3</td>\n",
" <td>23</td>\n",
" <td>2.65</td>\n",
" <td>7.0225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>clover 6</td>\n",
" <td>6</td>\n",
" <td>hearts 8</td>\n",
" <td>8</td>\n",
" <td>hearts 6</td>\n",
" <td>6</td>\n",
" <td>20</td>\n",
" <td>-0.35</td>\n",
" <td>0.1225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>diamond 6</td>\n",
" <td>6</td>\n",
" <td>clover 2</td>\n",
" <td>2</td>\n",
" <td>clover king</td>\n",
" <td>10</td>\n",
" <td>18</td>\n",
" <td>-2.35</td>\n",
" <td>5.5225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>spades 2</td>\n",
" <td>2</td>\n",
" <td>clover 6</td>\n",
" <td>6</td>\n",
" <td>hearts 8</td>\n",
" <td>8</td>\n",
" <td>16</td>\n",
" <td>-4.35</td>\n",
" <td>18.9225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>spades 5</td>\n",
" <td>5</td>\n",
" <td>diamond 5</td>\n",
" <td>5</td>\n",
" <td>spades 6</td>\n",
" <td>6</td>\n",
" <td>16</td>\n",
" <td>-4.35</td>\n",
" <td>18.9225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>clover 9</td>\n",
" <td>9</td>\n",
" <td>diamond 7</td>\n",
" <td>7</td>\n",
" <td>spades 9</td>\n",
" <td>9</td>\n",
" <td>25</td>\n",
" <td>4.65</td>\n",
" <td>21.6225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30</th>\n",
" <td>diamond queen</td>\n",
" <td>10</td>\n",
" <td>hearts 10</td>\n",
" <td>10</td>\n",
" <td>clover 4</td>\n",
" <td>4</td>\n",
" <td>24</td>\n",
" <td>3.65</td>\n",
" <td>13.3225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>31</th>\n",
" <td>clover ace</td>\n",
" <td>1</td>\n",
" <td>clover 3</td>\n",
" <td>3</td>\n",
" <td>hearts 3</td>\n",
" <td>3</td>\n",
" <td>7</td>\n",
" <td>-13.35</td>\n",
" <td>178.2225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>32</th>\n",
" <td>hearts 6</td>\n",
" <td>6</td>\n",
" <td>hearts 4</td>\n",
" <td>4</td>\n",
" <td>clover 5</td>\n",
" <td>5</td>\n",
" <td>15</td>\n",
" <td>-5.35</td>\n",
" <td>28.6225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>33</th>\n",
" <td>hearts bishop</td>\n",
" <td>10</td>\n",
" <td>spades 10</td>\n",
" <td>10</td>\n",
" <td>clover 4</td>\n",
" <td>4</td>\n",
" <td>24</td>\n",
" <td>3.65</td>\n",
" <td>13.3225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>34</th>\n",
" <td>spades 10</td>\n",
" <td>10</td>\n",
" <td>spades 7</td>\n",
" <td>7</td>\n",
" <td>spades queen</td>\n",
" <td>10</td>\n",
" <td>27</td>\n",
" <td>6.65</td>\n",
" <td>44.2225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>35</th>\n",
" <td>spades 9</td>\n",
" <td>9</td>\n",
" <td>diamond 3</td>\n",
" <td>3</td>\n",
" <td>diamond bishop</td>\n",
" <td>10</td>\n",
" <td>22</td>\n",
" <td>1.65</td>\n",
" <td>2.7225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>36</th>\n",
" <td>spades 9</td>\n",
" <td>9</td>\n",
" <td>hearts 3</td>\n",
" <td>3</td>\n",
" <td>clover 4</td>\n",
" <td>4</td>\n",
" <td>16</td>\n",
" <td>-4.35</td>\n",
" <td>18.9225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>37</th>\n",
" <td>diamond queen</td>\n",
" <td>10</td>\n",
" <td>diamond 6</td>\n",
" <td>6</td>\n",
" <td>diamond 10</td>\n",
" <td>10</td>\n",
" <td>26</td>\n",
" <td>5.65</td>\n",
" <td>31.9225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>38</th>\n",
" <td>hearts 10</td>\n",
" <td>10</td>\n",
" <td>spades 10</td>\n",
" <td>10</td>\n",
" <td>spades king</td>\n",
" <td>10</td>\n",
" <td>30</td>\n",
" <td>9.65</td>\n",
" <td>93.1225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>39</th>\n",
" <td>hearts 6</td>\n",
" <td>6</td>\n",
" <td>clover 8</td>\n",
" <td>8</td>\n",
" <td>spades 8</td>\n",
" <td>8</td>\n",
" <td>22</td>\n",
" <td>1.65</td>\n",
" <td>2.7225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>40</th>\n",
" <td>hearts 9</td>\n",
" <td>9</td>\n",
" <td>clover 4</td>\n",
" <td>4</td>\n",
" <td>diamond 3</td>\n",
" <td>3</td>\n",
" <td>16</td>\n",
" <td>-4.35</td>\n",
" <td>18.9225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>41</th>\n",
" <td>clover king</td>\n",
" <td>10</td>\n",
" <td>diamond bishop</td>\n",
" <td>10</td>\n",
" <td>diamond queen</td>\n",
" <td>10</td>\n",
" <td>30</td>\n",
" <td>9.65</td>\n",
" <td>93.1225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>42</th>\n",
" <td>hearts ace</td>\n",
" <td>1</td>\n",
" <td>hearts queen</td>\n",
" <td>10</td>\n",
" <td>spades bishop</td>\n",
" <td>10</td>\n",
" <td>21</td>\n",
" <td>0.65</td>\n",
" <td>0.4225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>43</th>\n",
" <td>hearts 10</td>\n",
" <td>10</td>\n",
" <td>hearts king</td>\n",
" <td>10</td>\n",
" <td>spades 7</td>\n",
" <td>7</td>\n",
" <td>27</td>\n",
" <td>6.65</td>\n",
" <td>44.2225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>44</th>\n",
" <td>diamond 8</td>\n",
" <td>8</td>\n",
" <td>spades 7</td>\n",
" <td>7</td>\n",
" <td>diamond 9</td>\n",
" <td>9</td>\n",
" <td>24</td>\n",
" <td>3.65</td>\n",
" <td>13.3225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>45</th>\n",
" <td>spades 10</td>\n",
" <td>10</td>\n",
" <td>diamond 4</td>\n",
" <td>4</td>\n",
" <td>clover 4</td>\n",
" <td>4</td>\n",
" <td>18</td>\n",
" <td>-2.35</td>\n",
" <td>5.5225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>46</th>\n",
" <td>spades 8</td>\n",
" <td>8</td>\n",
" <td>hearts 3</td>\n",
" <td>3</td>\n",
" <td>hearts 2</td>\n",
" <td>2</td>\n",
" <td>13</td>\n",
" <td>-7.35</td>\n",
" <td>54.0225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>47</th>\n",
" <td>hearts 9</td>\n",
" <td>9</td>\n",
" <td>diamond 7</td>\n",
" <td>7</td>\n",
" <td>clover king</td>\n",
" <td>10</td>\n",
" <td>26</td>\n",
" <td>5.65</td>\n",
" <td>31.9225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>48</th>\n",
" <td>clover 8</td>\n",
" <td>8</td>\n",
" <td>diamond 4</td>\n",
" <td>4</td>\n",
" <td>hearts 8</td>\n",
" <td>8</td>\n",
" <td>20</td>\n",
" <td>-0.35</td>\n",
" <td>0.1225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>49</th>\n",
" <td>hearts 7</td>\n",
" <td>7</td>\n",
" <td>diamond 9</td>\n",
" <td>9</td>\n",
" <td>clover queen</td>\n",
" <td>10</td>\n",
" <td>26</td>\n",
" <td>5.65</td>\n",
" <td>31.9225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50</th>\n",
" <td>clover 9</td>\n",
" <td>9</td>\n",
" <td>bishop 4</td>\n",
" <td>4</td>\n",
" <td>clover bishop</td>\n",
" <td>10</td>\n",
" <td>23</td>\n",
" <td>2.65</td>\n",
" <td>7.0225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>51</th>\n",
" <td>diamond ace</td>\n",
" <td>1</td>\n",
" <td>diamond 5</td>\n",
" <td>5</td>\n",
" <td>hearts 9</td>\n",
" <td>9</td>\n",
" <td>15</td>\n",
" <td>-5.35</td>\n",
" <td>28.6225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>52</th>\n",
" <td>hearts queen</td>\n",
" <td>10</td>\n",
" <td>diamond bishop</td>\n",
" <td>10</td>\n",
" <td>spades 5</td>\n",
" <td>5</td>\n",
" <td>25</td>\n",
" <td>4.65</td>\n",
" <td>21.6225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>53</th>\n",
" <td>diamond 9</td>\n",
" <td>9</td>\n",
" <td>diamond queen</td>\n",
" <td>10</td>\n",
" <td>spades king</td>\n",
" <td>10</td>\n",
" <td>29</td>\n",
" <td>8.65</td>\n",
" <td>74.8225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>54</th>\n",
" <td>hearts 3</td>\n",
" <td>3</td>\n",
" <td>clover 6</td>\n",
" <td>6</td>\n",
" <td>diamond 5</td>\n",
" <td>5</td>\n",
" <td>14</td>\n",
" <td>-6.35</td>\n",
" <td>40.3225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>55</th>\n",
" <td>clover 6</td>\n",
" <td>6</td>\n",
" <td>spades king</td>\n",
" <td>10</td>\n",
" <td>spades 4</td>\n",
" <td>4</td>\n",
" <td>20</td>\n",
" <td>-0.35</td>\n",
" <td>0.1225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>56</th>\n",
" <td>diamond 2</td>\n",
" <td>2</td>\n",
" <td>hearts 9</td>\n",
" <td>9</td>\n",
" <td>clover queen</td>\n",
" <td>10</td>\n",
" <td>21</td>\n",
" <td>0.65</td>\n",
" <td>0.4225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>57</th>\n",
" <td>spades king</td>\n",
" <td>10</td>\n",
" <td>diamond queen</td>\n",
" <td>10</td>\n",
" <td>hearts 7</td>\n",
" <td>7</td>\n",
" <td>27</td>\n",
" <td>6.65</td>\n",
" <td>44.2225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>58</th>\n",
" <td>clover 10</td>\n",
" <td>10</td>\n",
" <td>spades 5</td>\n",
" <td>5</td>\n",
" <td>cover 7</td>\n",
" <td>7</td>\n",
" <td>22</td>\n",
" <td>1.65</td>\n",
" <td>2.7225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>59</th>\n",
" <td>clover king</td>\n",
" <td>10</td>\n",
" <td>spades 5</td>\n",
" <td>5</td>\n",
" <td>clover 9</td>\n",
" <td>9</td>\n",
" <td>24</td>\n",
" <td>3.65</td>\n",
" <td>13.3225</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" card 1 name card 1 value card 2 name card 2 value \\\n",
"0 clover king 10 spades 10 10 \n",
"1 spades 4 4 hearts 4 4 \n",
"2 clover 2 2 diamond 9 9 \n",
"3 diamond queen 10 hearts 10 10 \n",
"4 spades 9 9 clover 7 7 \n",
"5 clover king 10 clover 2 2 \n",
"6 hearts 4 4 hearts king 10 \n",
"7 hearts bishop 10 hearts queen 10 \n",
"8 clover king 10 diamond 3 3 \n",
"9 clover ace 1 hearts 5 5 \n",
"10 hearts king 10 bishop 10 10 \n",
"11 hears bishop 10 clover king 10 \n",
"12 clover 5 5 clover 6 6 \n",
"13 diamond ace 1 diamond bishop 10 \n",
"14 diamond 5 5 diamond bishop 10 \n",
"15 hearts ace 1 hearts 8 8 \n",
"16 diamond 7 7 clover 9 9 \n",
"17 hearts king 10 diamond 7 7 \n",
"18 hearts 3 3 spades bishop 10 \n",
"19 diamond bishop 10 diamond 2 2 \n",
"20 diamond 4 4 clover 9 9 \n",
"21 hearts 3 3 diamond 5 5 \n",
"22 hearts 4 4 clover 9 9 \n",
"23 spades 2 2 diamond 3 3 \n",
"24 spades bishop 10 hearts bishop 10 \n",
"25 clover 6 6 hearts 8 8 \n",
"26 diamond 6 6 clover 2 2 \n",
"27 spades 2 2 clover 6 6 \n",
"28 spades 5 5 diamond 5 5 \n",
"29 clover 9 9 diamond 7 7 \n",
"30 diamond queen 10 hearts 10 10 \n",
"31 clover ace 1 clover 3 3 \n",
"32 hearts 6 6 hearts 4 4 \n",
"33 hearts bishop 10 spades 10 10 \n",
"34 spades 10 10 spades 7 7 \n",
"35 spades 9 9 diamond 3 3 \n",
"36 spades 9 9 hearts 3 3 \n",
"37 diamond queen 10 diamond 6 6 \n",
"38 hearts 10 10 spades 10 10 \n",
"39 hearts 6 6 clover 8 8 \n",
"40 hearts 9 9 clover 4 4 \n",
"41 clover king 10 diamond bishop 10 \n",
"42 hearts ace 1 hearts queen 10 \n",
"43 hearts 10 10 hearts king 10 \n",
"44 diamond 8 8 spades 7 7 \n",
"45 spades 10 10 diamond 4 4 \n",
"46 spades 8 8 hearts 3 3 \n",
"47 hearts 9 9 diamond 7 7 \n",
"48 clover 8 8 diamond 4 4 \n",
"49 hearts 7 7 diamond 9 9 \n",
"50 clover 9 9 bishop 4 4 \n",
"51 diamond ace 1 diamond 5 5 \n",
"52 hearts queen 10 diamond bishop 10 \n",
"53 diamond 9 9 diamond queen 10 \n",
"54 hearts 3 3 clover 6 6 \n",
"55 clover 6 6 spades king 10 \n",
"56 diamond 2 2 hearts 9 9 \n",
"57 spades king 10 diamond queen 10 \n",
"58 clover 10 10 spades 5 5 \n",
"59 clover king 10 spades 5 5 \n",
"\n",
" card 3 name card 3 value sum of card values deviation from mean sum \\\n",
"0 spades 2 2 22 1.65 \n",
"1 hearts 10 10 18 -2.35 \n",
"2 spades 7 7 18 -2.35 \n",
"3 diamond 6 6 26 5.65 \n",
"4 spades ace 1 17 -3.35 \n",
"5 clover 6 6 18 -2.35 \n",
"6 clover 5 5 19 -1.35 \n",
"7 spades 4 4 24 3.65 \n",
"8 heart bishop 10 23 2.65 \n",
"9 clover 7 7 13 -7.35 \n",
"10 hearts ace 1 21 0.65 \n",
"11 hearts 5 5 25 4.65 \n",
"12 hearts ace 1 12 -8.35 \n",
"13 diamond 5 5 16 -4.35 \n",
"14 clover 9 9 24 3.65 \n",
"15 clover king 10 19 -1.35 \n",
"16 clover 8 8 24 3.65 \n",
"17 hearts 5 5 22 1.65 \n",
"18 clover 6 6 19 -1.35 \n",
"19 clover 2 2 14 -6.35 \n",
"20 diamond 2 2 15 -5.35 \n",
"21 diamond 3 3 11 -9.35 \n",
"22 hearts 2 2 15 -5.35 \n",
"23 spades 9 9 14 -6.35 \n",
"24 bishop 3 3 23 2.65 \n",
"25 hearts 6 6 20 -0.35 \n",
"26 clover king 10 18 -2.35 \n",
"27 hearts 8 8 16 -4.35 \n",
"28 spades 6 6 16 -4.35 \n",
"29 spades 9 9 25 4.65 \n",
"30 clover 4 4 24 3.65 \n",
"31 hearts 3 3 7 -13.35 \n",
"32 clover 5 5 15 -5.35 \n",
"33 clover 4 4 24 3.65 \n",
"34 spades queen 10 27 6.65 \n",
"35 diamond bishop 10 22 1.65 \n",
"36 clover 4 4 16 -4.35 \n",
"37 diamond 10 10 26 5.65 \n",
"38 spades king 10 30 9.65 \n",
"39 spades 8 8 22 1.65 \n",
"40 diamond 3 3 16 -4.35 \n",
"41 diamond queen 10 30 9.65 \n",
"42 spades bishop 10 21 0.65 \n",
"43 spades 7 7 27 6.65 \n",
"44 diamond 9 9 24 3.65 \n",
"45 clover 4 4 18 -2.35 \n",
"46 hearts 2 2 13 -7.35 \n",
"47 clover king 10 26 5.65 \n",
"48 hearts 8 8 20 -0.35 \n",
"49 clover queen 10 26 5.65 \n",
"50 clover bishop 10 23 2.65 \n",
"51 hearts 9 9 15 -5.35 \n",
"52 spades 5 5 25 4.65 \n",
"53 spades king 10 29 8.65 \n",
"54 diamond 5 5 14 -6.35 \n",
"55 spades 4 4 20 -0.35 \n",
"56 clover queen 10 21 0.65 \n",
"57 hearts 7 7 27 6.65 \n",
"58 cover 7 7 22 1.65 \n",
"59 clover 9 9 24 3.65 \n",
"\n",
" squared deviations \n",
"0 2.7225 \n",
"1 5.5225 \n",
"2 5.5225 \n",
"3 31.9225 \n",
"4 11.2225 \n",
"5 5.5225 \n",
"6 1.8225 \n",
"7 13.3225 \n",
"8 7.0225 \n",
"9 54.0225 \n",
"10 0.4225 \n",
"11 21.6225 \n",
"12 69.7225 \n",
"13 18.9225 \n",
"14 13.3225 \n",
"15 1.8225 \n",
"16 13.3225 \n",
"17 2.7225 \n",
"18 1.8225 \n",
"19 40.3225 \n",
"20 28.6225 \n",
"21 87.4225 \n",
"22 28.6225 \n",
"23 40.3225 \n",
"24 7.0225 \n",
"25 0.1225 \n",
"26 5.5225 \n",
"27 18.9225 \n",
"28 18.9225 \n",
"29 21.6225 \n",
"30 13.3225 \n",
"31 178.2225 \n",
"32 28.6225 \n",
"33 13.3225 \n",
"34 44.2225 \n",
"35 2.7225 \n",
"36 18.9225 \n",
"37 31.9225 \n",
"38 93.1225 \n",
"39 2.7225 \n",
"40 18.9225 \n",
"41 93.1225 \n",
"42 0.4225 \n",
"43 44.2225 \n",
"44 13.3225 \n",
"45 5.5225 \n",
"46 54.0225 \n",
"47 31.9225 \n",
"48 0.1225 \n",
"49 31.9225 \n",
"50 7.0225 \n",
"51 28.6225 \n",
"52 21.6225 \n",
"53 74.8225 \n",
"54 40.3225 \n",
"55 0.1225 \n",
"56 0.4225 \n",
"57 44.2225 \n",
"58 2.7225 \n",
"59 13.3225 "
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# or the complete table imported in pandas:\n",
"table"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment