{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "IPython.OutputArea.prototype._should_scroll = function(lines) {\n", " return false;\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%%javascript\n", "IPython.OutputArea.prototype._should_scroll = function(lines) {\n", " return false;\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Let's Clean Some Data\n", "\n", "Fivethirtyeight has some great data sets and this is one of them. In July 2014, before the third Star Wars trilogy was released, they decided to survey Americans to see which of the first six movies was their favorite. Let's take a look at the results. Some light cleaning should make it more usable!" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "scrolled": false }, "outputs": [], "source": [ "# import libraries and csv\n", "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "star_wars = pd.read_csv(\"star_wars.csv\", encoding=\"ISO-8859-1\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
RespondentIDHave you seen any of the 6 films in the Star Wars franchise?Do you consider yourself to be a fan of the Star Wars film franchise?Which of the following Star Wars films have you seen? Please select all that apply.Unnamed: 4Unnamed: 5Unnamed: 6Unnamed: 7Unnamed: 8Please rank the Star Wars films in order of preference with 1 being your favorite film in the franchise and 6 being your least favorite film....Unnamed: 28Which character shot first?Are you familiar with the Expanded Universe?Do you consider yourself to be a fan of the Expanded Universe?Do you consider yourself to be a fan of the Star Trek franchise?GenderAgeHousehold IncomeEducationLocation (Census Region)
03292879998YesYesStar Wars: Episode I The Phantom MenaceStar Wars: Episode II Attack of the ClonesStar Wars: Episode III Revenge of the SithStar Wars: Episode IV A New HopeStar Wars: Episode V The Empire Strikes BackStar Wars: Episode VI Return of the Jedi3.0...Very favorablyI don't understand this questionYesNoNoMale18-29NaNHigh school degreeSouth Atlantic
13292879538NoNaNNaNNaNNaNNaNNaNNaNNaN...NaNNaNNaNNaNYesMale18-29$0 - $24,999Bachelor degreeWest South Central
23292765271YesNoStar Wars: Episode I The Phantom MenaceStar Wars: Episode II Attack of the ClonesStar Wars: Episode III Revenge of the SithNaNNaNNaN1.0...Unfamiliar (N/A)I don't understand this questionNoNaNNoMale18-29$0 - $24,999High school degreeWest North Central
33292763116YesYesStar Wars: Episode I The Phantom MenaceStar Wars: Episode II Attack of the ClonesStar Wars: Episode III Revenge of the SithStar Wars: Episode IV A New HopeStar Wars: Episode V The Empire Strikes BackStar Wars: Episode VI Return of the Jedi5.0...Very favorablyI don't understand this questionNoNaNYesMale18-29$100,000 - $149,999Some college or Associate degreeWest North Central
43292731220YesYesStar Wars: Episode I The Phantom MenaceStar Wars: Episode II Attack of the ClonesStar Wars: Episode III Revenge of the SithStar Wars: Episode IV A New HopeStar Wars: Episode V The Empire Strikes BackStar Wars: Episode VI Return of the Jedi5.0...Somewhat favorablyGreedoYesNoNoMale18-29$100,000 - $149,999Some college or Associate degreeWest North Central
53292719380YesYesStar Wars: Episode I The Phantom MenaceStar Wars: Episode II Attack of the ClonesStar Wars: Episode III Revenge of the SithStar Wars: Episode IV A New HopeStar Wars: Episode V The Empire Strikes BackStar Wars: Episode VI Return of the Jedi1.0...Very favorablyHanYesNoYesMale18-29$25,000 - $49,999Bachelor degreeMiddle Atlantic
63292684787YesYesStar Wars: Episode I The Phantom MenaceStar Wars: Episode II Attack of the ClonesStar Wars: Episode III Revenge of the SithStar Wars: Episode IV A New HopeStar Wars: Episode V The Empire Strikes BackStar Wars: Episode VI Return of the Jedi6.0...Very favorablyHanYesNoNoMale18-29NaNHigh school degreeEast North Central
73292663732YesYesStar Wars: Episode I The Phantom MenaceStar Wars: Episode II Attack of the ClonesStar Wars: Episode III Revenge of the SithStar Wars: Episode IV A New HopeStar Wars: Episode V The Empire Strikes BackStar Wars: Episode VI Return of the Jedi4.0...Very favorablyHanNoNaNYesMale18-29NaNHigh school degreeSouth Atlantic
83292654043YesYesStar Wars: Episode I The Phantom MenaceStar Wars: Episode II Attack of the ClonesStar Wars: Episode III Revenge of the SithStar Wars: Episode IV A New HopeStar Wars: Episode V The Empire Strikes BackStar Wars: Episode VI Return of the Jedi5.0...Somewhat favorablyHanNoNaNNoMale18-29$0 - $24,999Some college or Associate degreeSouth Atlantic
93292640424YesNoNaNStar Wars: Episode II Attack of the ClonesNaNNaNNaNNaN1.0...Very favorablyI don't understand this questionNoNaNNoMale18-29$25,000 - $49,999Some college or Associate degreePacific
\n", "

10 rows × 38 columns

\n", "
" ], "text/plain": [ " RespondentID Have you seen any of the 6 films in the Star Wars franchise? \\\n", "0 3292879998 Yes \n", "1 3292879538 No \n", "2 3292765271 Yes \n", "3 3292763116 Yes \n", "4 3292731220 Yes \n", "5 3292719380 Yes \n", "6 3292684787 Yes \n", "7 3292663732 Yes \n", "8 3292654043 Yes \n", "9 3292640424 Yes \n", "\n", " Do you consider yourself to be a fan of the Star Wars film franchise? \\\n", "0 Yes \n", "1 NaN \n", "2 No \n", "3 Yes \n", "4 Yes \n", "5 Yes \n", "6 Yes \n", "7 Yes \n", "8 Yes \n", "9 No \n", "\n", " Which of the following Star Wars films have you seen? Please select all that apply. \\\n", "0 Star Wars: Episode I The Phantom Menace \n", "1 NaN \n", "2 Star Wars: Episode I The Phantom Menace \n", "3 Star Wars: Episode I The Phantom Menace \n", "4 Star Wars: Episode I The Phantom Menace \n", "5 Star Wars: Episode I The Phantom Menace \n", "6 Star Wars: Episode I The Phantom Menace \n", "7 Star Wars: Episode I The Phantom Menace \n", "8 Star Wars: Episode I The Phantom Menace \n", "9 NaN \n", "\n", " Unnamed: 4 \\\n", "0 Star Wars: Episode II Attack of the Clones \n", "1 NaN \n", "2 Star Wars: Episode II Attack of the Clones \n", "3 Star Wars: Episode II Attack of the Clones \n", "4 Star Wars: Episode II Attack of the Clones \n", "5 Star Wars: Episode II Attack of the Clones \n", "6 Star Wars: Episode II Attack of the Clones \n", "7 Star Wars: Episode II Attack of the Clones \n", "8 Star Wars: Episode II Attack of the Clones \n", "9 Star Wars: Episode II Attack of the Clones \n", "\n", " Unnamed: 5 \\\n", "0 Star Wars: Episode III Revenge of the Sith \n", "1 NaN \n", "2 Star Wars: Episode III Revenge of the Sith \n", "3 Star Wars: Episode III Revenge of the Sith \n", "4 Star Wars: Episode III Revenge of the Sith \n", "5 Star Wars: Episode III Revenge of the Sith \n", "6 Star Wars: Episode III Revenge of the Sith \n", "7 Star Wars: Episode III Revenge of the Sith \n", "8 Star Wars: Episode III Revenge of the Sith \n", "9 NaN \n", "\n", " Unnamed: 6 \\\n", "0 Star Wars: Episode IV A New Hope \n", "1 NaN \n", "2 NaN \n", "3 Star Wars: Episode IV A New Hope \n", "4 Star Wars: Episode IV A New Hope \n", "5 Star Wars: Episode IV A New Hope \n", "6 Star Wars: Episode IV A New Hope \n", "7 Star Wars: Episode IV A New Hope \n", "8 Star Wars: Episode IV A New Hope \n", "9 NaN \n", "\n", " Unnamed: 7 \\\n", "0 Star Wars: Episode V The Empire Strikes Back \n", "1 NaN \n", "2 NaN \n", "3 Star Wars: Episode V The Empire Strikes Back \n", "4 Star Wars: Episode V The Empire Strikes Back \n", "5 Star Wars: Episode V The Empire Strikes Back \n", "6 Star Wars: Episode V The Empire Strikes Back \n", "7 Star Wars: Episode V The Empire Strikes Back \n", "8 Star Wars: Episode V The Empire Strikes Back \n", "9 NaN \n", "\n", " Unnamed: 8 \\\n", "0 Star Wars: Episode VI Return of the Jedi \n", "1 NaN \n", "2 NaN \n", "3 Star Wars: Episode VI Return of the Jedi \n", "4 Star Wars: Episode VI Return of the Jedi \n", "5 Star Wars: Episode VI Return of the Jedi \n", "6 Star Wars: Episode VI Return of the Jedi \n", "7 Star Wars: Episode VI Return of the Jedi \n", "8 Star Wars: Episode VI Return of the Jedi \n", "9 NaN \n", "\n", " Please rank the Star Wars films in order of preference with 1 being your favorite film in the franchise and 6 being your least favorite film. \\\n", "0 3.0 \n", "1 NaN \n", "2 1.0 \n", "3 5.0 \n", "4 5.0 \n", "5 1.0 \n", "6 6.0 \n", "7 4.0 \n", "8 5.0 \n", "9 1.0 \n", "\n", " ... Unnamed: 28 Which character shot first? \\\n", "0 ... Very favorably I don't understand this question \n", "1 ... NaN NaN \n", "2 ... Unfamiliar (N/A) I don't understand this question \n", "3 ... Very favorably I don't understand this question \n", "4 ... Somewhat favorably Greedo \n", "5 ... Very favorably Han \n", "6 ... Very favorably Han \n", "7 ... Very favorably Han \n", "8 ... Somewhat favorably Han \n", "9 ... Very favorably I don't understand this question \n", "\n", " Are you familiar with the Expanded Universe? \\\n", "0 Yes \n", "1 NaN \n", "2 No \n", "3 No \n", "4 Yes \n", "5 Yes \n", "6 Yes \n", "7 No \n", "8 No \n", "9 No \n", "\n", " Do you consider yourself to be a fan of the Expanded Universe? \\\n", "0 No \n", "1 NaN \n", "2 NaN \n", "3 NaN \n", "4 No \n", "5 No \n", "6 No \n", "7 NaN \n", "8 NaN \n", "9 NaN \n", "\n", " Do you consider yourself to be a fan of the Star Trek franchise? Gender \\\n", "0 No Male \n", "1 Yes Male \n", "2 No Male \n", "3 Yes Male \n", "4 No Male \n", "5 Yes Male \n", "6 No Male \n", "7 Yes Male \n", "8 No Male \n", "9 No Male \n", "\n", " Age Household Income Education \\\n", "0 18-29 NaN High school degree \n", "1 18-29 $0 - $24,999 Bachelor degree \n", "2 18-29 $0 - $24,999 High school degree \n", "3 18-29 $100,000 - $149,999 Some college or Associate degree \n", "4 18-29 $100,000 - $149,999 Some college or Associate degree \n", "5 18-29 $25,000 - $49,999 Bachelor degree \n", "6 18-29 NaN High school degree \n", "7 18-29 NaN High school degree \n", "8 18-29 $0 - $24,999 Some college or Associate degree \n", "9 18-29 $25,000 - $49,999 Some college or Associate degree \n", "\n", " Location (Census Region) \n", "0 South Atlantic \n", "1 West South Central \n", "2 West North Central \n", "3 West North Central \n", "4 West North Central \n", "5 Middle Atlantic \n", "6 East North Central \n", "7 South Atlantic \n", "8 South Atlantic \n", "9 Pacific \n", "\n", "[10 rows x 38 columns]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "Index(['RespondentID',\n", " 'Have you seen any of the 6 films in the Star Wars franchise?',\n", " 'Do you consider yourself to be a fan of the Star Wars film franchise?',\n", " 'Which of the following Star Wars films have you seen? Please select all that apply.',\n", " 'Unnamed: 4', 'Unnamed: 5', 'Unnamed: 6', 'Unnamed: 7', 'Unnamed: 8',\n", " 'Please rank the Star Wars films in order of preference with 1 being your favorite film in the franchise and 6 being your least favorite film.',\n", " 'Unnamed: 10', 'Unnamed: 11', 'Unnamed: 12', 'Unnamed: 13',\n", " 'Unnamed: 14',\n", " 'Please state whether you view the following characters favorably, unfavorably, or are unfamiliar with him/her.',\n", " 'Unnamed: 16', 'Unnamed: 17', 'Unnamed: 18', 'Unnamed: 19',\n", " 'Unnamed: 20', 'Unnamed: 21', 'Unnamed: 22', 'Unnamed: 23',\n", " 'Unnamed: 24', 'Unnamed: 25', 'Unnamed: 26', 'Unnamed: 27',\n", " 'Unnamed: 28', 'Which character shot first?',\n", " 'Are you familiar with the Expanded Universe?',\n", " 'Do you consider yourself to be a fan of the Expanded Universe?',\n", " 'Do you consider yourself to be a fan of the Star Trek franchise?',\n", " 'Gender', 'Age', 'Household Income', 'Education',\n", " 'Location (Census Region)'],\n", " dtype='object')" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "(1186, 38)" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# explore the data frame\n", "display(star_wars.head(10))\n", "display(star_wars.columns)\n", "display(star_wars.shape)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# rename columns\n", "new_columns = {\"Have you seen any of the 6 films in the Star Wars franchise?\":\"Seen any of the first 6 Star Wars movies?\",\n", " \"Do you consider yourself to be a fan of the Star Wars film franchise?\":\"Fan of the Star Wars franchise?\",\n", " \"Which of the following Star Wars films have you seen? Please select all that apply.\" : \"seen_ep_1\",\n", " \"Unnamed: 4\" : \"seen_ep_2\",\n", " \"Unnamed: 5\" : \"seen_ep_3\",\n", " \"Unnamed: 6\" : \"seen_ep_4\",\n", " \"Unnamed: 7\" : \"seen_ep_5\",\n", " \"Unnamed: 8\" : \"seen_ep_6\",\n", " \"Please rank the Star Wars films in order of preference with 1 being your favorite film in the franchise and 6 being your least favorite film.\":\"rank_ep_1\",\n", " \"Unnamed: 10\":\"rank_ep_2\",\n", " \"Unnamed: 11\":\"rank_ep_3\",\n", " \"Unnamed: 12\":\"rank_ep_4\",\n", " \"Unnamed: 13\":\"rank_ep_5\",\n", " \"Unnamed: 14\":\"rank_ep_6\"}\n", "\n", "star_wars = star_wars.rename(columns = new_columns)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Yes 936\n", "No 250\n", "Name: Seen any of the first 6 Star Wars movies?, dtype: int64\n", "Yes 552\n", "NaN 350\n", "No 284\n", "Name: Fan of the Star Wars franchise?, dtype: int64\n", "Star Wars: Episode I The Phantom Menace 673\n", "NaN 513\n", "Name: seen_ep_1, dtype: int64\n" ] } ], "source": [ "# value counts for columns 1:3\n", "print(star_wars[\"Seen any of the first 6 Star Wars movies?\"].value_counts(dropna=False))\n", "print(star_wars[\"Fan of the Star Wars franchise?\"].value_counts(dropna=False))\n", "print(star_wars[\"seen_ep_1\"].value_counts(dropna=False))" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "True 936\n", "False 250\n", "Name: Seen any of the first 6 Star Wars movies?, dtype: int64\n", "True 552\n", "NaN 350\n", "False 284\n", "Name: Fan of the Star Wars franchise?, dtype: int64\n" ] }, { "data": { "text/plain": [ "True 673\n", "False 513\n", "Name: seen_ep_1, dtype: int64" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# switch values to boolean for columns 1:2\n", "yes_no_bool = {\"Yes\":True, \"No\":False}\n", "star_wars[\"Seen any of the first 6 Star Wars movies?\"] = star_wars[\"Seen any of the first 6 Star Wars movies?\"].map(yes_no_bool)\n", "star_wars[\"Fan of the Star Wars franchise?\"] = star_wars[\"Fan of the Star Wars franchise?\"].map(yes_no_bool)\n", "\n", "\n", "# switch values to boolean for columns 3:9\n", "watch_bool = {\"Star Wars: Episode I The Phantom Menace\" : True,\n", " \"Star Wars: Episode II Attack of the Clones\" : True,\n", " \"Star Wars: Episode III Revenge of the Sith\" : True,\n", " \"Star Wars: Episode IV A New Hope\" : True,\n", " \"Star Wars: Episode V The Empire Strikes Back\" : True,\n", " \"Star Wars: Episode VI Return of the Jedi\" : True,\n", " np.NaN : False}\n", "\n", "for col in star_wars.columns[3:9]:\n", " star_wars[col] = star_wars[col].map(watch_bool)\n", "\n", "# value counts for columns 1:3\n", "print(star_wars[\"Seen any of the first 6 Star Wars movies?\"].value_counts(dropna=False))\n", "print(star_wars[\"Fan of the Star Wars franchise?\"].value_counts(dropna=False))\n", "display(star_wars.iloc[:,3].value_counts(dropna=False))" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dtype('float64')" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# convert rankings to float\n", "star_wars[star_wars.columns[9:15]] = star_wars[star_wars.columns[9:15]].astype(float)\n", "\n", "# star_wars.columns[9].dtype # why does this work sometimes?\n", "star_wars.iloc[:,9].dtype" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
rank_ep_1rank_ep_2rank_ep_3rank_ep_4rank_ep_5rank_ep_6
03.02.01.04.05.06.0
1NaNNaNNaNNaNNaNNaN
21.02.03.04.05.06.0
35.06.01.02.04.03.0
45.04.06.02.01.03.0
\n", "
" ], "text/plain": [ " rank_ep_1 rank_ep_2 rank_ep_3 rank_ep_4 rank_ep_5 rank_ep_6\n", "0 3.0 2.0 1.0 4.0 5.0 6.0\n", "1 NaN NaN NaN NaN NaN NaN\n", "2 1.0 2.0 3.0 4.0 5.0 6.0\n", "3 5.0 6.0 1.0 2.0 4.0 3.0\n", "4 5.0 4.0 6.0 2.0 1.0 3.0" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "star_wars.iloc[:,9:15].head()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "4.0 237\n", "6.0 168\n", "3.0 130\n", "1.0 129\n", "5.0 100\n", "2.0 71\n", "Name: rank_ep_1, dtype: int64" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "star_wars.iloc[:,9].value_counts()" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2.0 232\n", "3.0 220\n", "1.0 146\n", "6.0 145\n", "4.0 57\n", "5.0 36\n", "Name: rank_ep_6, dtype: int64" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "star_wars.iloc[:,14].value_counts()" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "# star_wars.iloc[:,9] = \n", "star_wars.iloc[:,9:15] = star_wars.iloc[:,9:15].replace({1:6, 6:1, 2:5, 5:2, 3:4, 4:3})" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3.0 237\n", "1.0 168\n", "4.0 130\n", "6.0 129\n", "2.0 100\n", "5.0 71\n", "Name: rank_ep_1, dtype: int64" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "star_wars.iloc[:,9].value_counts()" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5.0 232\n", "4.0 220\n", "6.0 146\n", "1.0 145\n", "3.0 57\n", "2.0 36\n", "Name: rank_ep_6, dtype: int64" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "star_wars.iloc[:,14].value_counts()" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
rank_ep_1rank_ep_2rank_ep_3rank_ep_4rank_ep_5rank_ep_6
04.05.06.03.02.01.0
1NaNNaNNaNNaNNaNNaN
26.05.04.03.02.01.0
32.01.06.05.03.04.0
42.03.01.05.06.04.0
\n", "
" ], "text/plain": [ " rank_ep_1 rank_ep_2 rank_ep_3 rank_ep_4 rank_ep_5 rank_ep_6\n", "0 4.0 5.0 6.0 3.0 2.0 1.0\n", "1 NaN NaN NaN NaN NaN NaN\n", "2 6.0 5.0 4.0 3.0 2.0 1.0\n", "3 2.0 1.0 6.0 5.0 3.0 4.0\n", "4 2.0 3.0 1.0 5.0 6.0 4.0" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "star_wars.iloc[:,9:15].head()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.7" } }, "nbformat": 4, "nbformat_minor": 1 }