Queer European MD passionate about IT
Ver código fonte

Merge pull request #46 from mircealex/patch-1

Removed dot notation
Josh Devlin 7 anos atrás
pai
commit
bdfda708e5
1 arquivos alterados com 54 adições e 55 exclusões
  1. 54 55
      Mission288Solutions.ipynb

+ 54 - 55
Mission288Solutions.ipynb

@@ -16,7 +16,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 13,
+   "execution_count": 1,
    "metadata": {},
    "outputs": [
     {
@@ -176,7 +176,7 @@
        "2                103660           12055                  0.5  "
       ]
      },
-     "execution_count": 13,
+     "execution_count": 1,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -193,7 +193,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 14,
+   "execution_count": 2,
    "metadata": {},
    "outputs": [
     {
@@ -310,7 +310,7 @@
        "2        2.0          2.5  "
       ]
      },
-     "execution_count": 14,
+     "execution_count": 2,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -328,7 +328,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 15,
+   "execution_count": 3,
    "metadata": {},
    "outputs": [
     {
@@ -400,7 +400,7 @@
        "2           12055                  0.5  "
       ]
      },
-     "execution_count": 15,
+     "execution_count": 3,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -415,7 +415,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 16,
+   "execution_count": 4,
    "metadata": {},
    "outputs": [
     {
@@ -474,7 +474,7 @@
        "2  A Cure for Wellness  2016       3.0"
       ]
      },
-     "execution_count": 16,
+     "execution_count": 4,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -529,7 +529,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 17,
+   "execution_count": 5,
    "metadata": {},
    "outputs": [
     {
@@ -637,7 +637,7 @@
        "31                Captain America: Civil War  2016       4.5"
       ]
      },
-     "execution_count": 17,
+     "execution_count": 5,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -717,7 +717,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 18,
+   "execution_count": 6,
    "metadata": {},
    "outputs": [
     {
@@ -726,14 +726,13 @@
        "0"
       ]
      },
-     "execution_count": 18,
+     "execution_count": 6,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "sum(fandango_previous.Fandango_votes < 30)  # `fandango_previous.Fandango_votes` is the same\n",
-    "                                             # as `fandago_previous['Fandango_votes']`"
+    "sum(fandango_previous['Fandango_votes'] < 30)"
    ]
   },
   {
@@ -745,7 +744,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 19,
+   "execution_count": 7,
    "metadata": {},
    "outputs": [
     {
@@ -807,7 +806,7 @@
        "1           12640                  0.5  "
       ]
      },
-     "execution_count": 19,
+     "execution_count": 7,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -825,7 +824,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 20,
+   "execution_count": 8,
    "metadata": {},
    "outputs": [
     {
@@ -890,19 +889,19 @@
        "1           12640                  0.5  2015  "
       ]
      },
-     "execution_count": 20,
+     "execution_count": 8,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "fandango_previous['Year'] = fandango_previous.FILM.str[-5:-1]\n",
+    "fandango_previous['Year'] = fandango_previous['FILM'].str[-5:-1]\n",
     "fandango_previous.head(2)"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 21,
+   "execution_count": 9,
    "metadata": {},
    "outputs": [
     {
@@ -913,18 +912,18 @@
        "Name: Year, dtype: int64"
       ]
      },
-     "execution_count": 21,
+     "execution_count": 9,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "fandango_previous.Year.value_counts()"
+    "fandango_previous['Year'].value_counts()"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 22,
+   "execution_count": 10,
    "metadata": {},
    "outputs": [
     {
@@ -934,14 +933,14 @@
        "Name: Year, dtype: int64"
       ]
      },
-     "execution_count": 22,
+     "execution_count": 10,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "fandango_2015 = fandango_previous[fandango_previous.Year == '2015'].copy()\n",
-    "fandango_2015.Year.value_counts()"
+    "fandango_2015 = fandango_previous[fandango_previous['Year'] == '2015'].copy()\n",
+    "fandango_2015['Year'].value_counts()"
    ]
   },
   {
@@ -953,7 +952,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 23,
+   "execution_count": 11,
    "metadata": {},
    "outputs": [
     {
@@ -1005,7 +1004,7 @@
        "1             13 Hours  2016       4.5"
       ]
      },
-     "execution_count": 23,
+     "execution_count": 11,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -1016,7 +1015,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 24,
+   "execution_count": 12,
    "metadata": {},
    "outputs": [
     {
@@ -1027,18 +1026,18 @@
        "Name: year, dtype: int64"
       ]
      },
-     "execution_count": 24,
+     "execution_count": 12,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "fandango_after.year.value_counts()"
+    "fandango_after['year'].value_counts()"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 25,
+   "execution_count": 13,
    "metadata": {},
    "outputs": [
     {
@@ -1048,14 +1047,14 @@
        "Name: year, dtype: int64"
       ]
      },
-     "execution_count": 25,
+     "execution_count": 13,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "fandango_2016 = fandango_after[fandango_after.year == 2016].copy()\n",
-    "fandango_2016.year.value_counts()"
+    "fandango_2016 = fandango_after[fandango_after['year'] == 2016].copy()\n",
+    "fandango_2016['year'].value_counts()"
    ]
   },
   {
@@ -1071,7 +1070,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 26,
+   "execution_count": 14,
    "metadata": {},
    "outputs": [
     {
@@ -1091,8 +1090,8 @@
     "%matplotlib inline\n",
     "plt.style.use('fivethirtyeight')\n",
     "\n",
-    "fandango_2015.Fandango_Stars.plot.kde(label = '2015', legend = True, figsize = (8,5.5))\n",
-    "fandango_2016.fandango.plot.kde(label = '2016', legend = True)\n",
+    "fandango_2015['Fandango_Stars'].plot.kde(label = '2015', legend = True, figsize = (8,5.5))\n",
+    "fandango_2016['fandango'].plot.kde(label = '2016', legend = True)\n",
     "\n",
     "plt.title(\"Comparing distribution shapes for Fandango's ratings\\n(2015 vs 2016)\",\n",
     "          y = 1.07) # the `y` parameter pads the title upward\n",
@@ -1122,7 +1121,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 27,
+   "execution_count": 15,
    "metadata": {},
    "outputs": [
     {
@@ -1144,7 +1143,7 @@
        "Name: Fandango_Stars, dtype: float64"
       ]
      },
-     "execution_count": 27,
+     "execution_count": 15,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -1152,12 +1151,12 @@
    "source": [
     "print('2015' + '\\n' + '-' * 16) # To help us distinguish between the two tables immediately and\n",
     "                                # avoid silly mistakes as we read to and fro\n",
-    "fandango_2015.Fandango_Stars.value_counts(normalize = True).sort_index() * 100"
+    "fandango_2015['Fandango_Stars'].value_counts(normalize = True).sort_index() * 100"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 28,
+   "execution_count": 16,
    "metadata": {},
    "outputs": [
     {
@@ -1180,14 +1179,14 @@
        "Name: fandango, dtype: float64"
       ]
      },
-     "execution_count": 28,
+     "execution_count": 16,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
     "print('2016' + '\\n' + '-' * 16)\n",
-    "fandango_2016.fandango.value_counts(normalize = True).sort_index() * 100"
+    "fandango_2016['fandango'].value_counts(normalize = True).sort_index() * 100"
    ]
   },
   {
@@ -1207,7 +1206,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 29,
+   "execution_count": 17,
    "metadata": {},
    "outputs": [
     {
@@ -1262,20 +1261,20 @@
        "mode    4.500000  4.000000"
       ]
      },
-     "execution_count": 29,
+     "execution_count": 17,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "mean_2015 = fandango_2015.Fandango_Stars.mean()\n",
-    "mean_2016 = fandango_2016.fandango.mean()\n",
+    "mean_2015 = fandango_2015['Fandango_Stars'].mean()\n",
+    "mean_2016 = fandango_2016['fandango'].mean()\n",
     "\n",
-    "median_2015 = fandango_2015.Fandango_Stars.median()\n",
-    "median_2016 = fandango_2016.fandango.median()\n",
+    "median_2015 = fandango_2015['Fandango_Stars'].median()\n",
+    "median_2016 = fandango_2016['fandango'].median()\n",
     "\n",
-    "mode_2015 = fandango_2015.Fandango_Stars.mode()[0] # the output of Series.mode() is a bit uncommon\n",
-    "mode_2016 = fandango_2016.fandango.mode()[0]\n",
+    "mode_2015 = fandango_2015['Fandango_Stars'].mode()[0] # the output of Series.mode() is a bit uncommon\n",
+    "mode_2016 = fandango_2016['fandango'].mode()[0]\n",
     "\n",
     "summary = pd.DataFrame()\n",
     "summary['2015'] = [mean_2015, median_2015, mode_2015]\n",
@@ -1286,7 +1285,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 37,
+   "execution_count": 18,
    "metadata": {},
    "outputs": [
     {
@@ -1323,7 +1322,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 77,
+   "execution_count": 19,
    "metadata": {},
    "outputs": [
     {
@@ -1332,7 +1331,7 @@
        "0.048426835689519929"
       ]
      },
-     "execution_count": 77,
+     "execution_count": 19,
      "metadata": {},
      "output_type": "execute_result"
     }