In [255]:
%matplotlib inline 
import matplotlib.pyplot as plt 
import pandas 
import numpy as np

import statsmodels.api as sm
from statsmodels.sandbox.regression.predstd import wls_prediction_std

import plotly.plotly as py
import plotly.graph_objs as go
py.sign_in('erikrood','3eqsrype8v')

#source for dataset - http://eigentaste.berkeley.edu/dataset/
#stats package - http://statsmodels.sourceforge.net/devel/examples/generated/example_ols.html
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-255-c19d42597507> in <module>()
      3 import pandas
      4 import numpy as np
----> 5 import pyfpdf
      6 
      7 import statsmodels.api as sm

ImportError: No module named pyfpdf
In [24]:
#converting .dat file to read in as csv
jester_jokes = pandas.read_csv('/Users/erikrood/anaconda/bin/jester_ratings.dat',
                               \sep='\s+', header=None, skiprows=1) 
In [251]:
jester_jokes.head()
Out[251]:
0 1 2
0 1 7 -9.281
1 1 8 -9.281
2 1 13 -6.781
3 1 15 0.875
4 1 16 -9.656
In [26]:
df = jester_jokes [[1,2]] #pulling ItemID (corresponds to joke name) and rating into data fram
df.columns = ['ItemID', 'Rating'] #renaming columns
In [27]:
df.head() #list of all of the item IDs and their associated ratings
Out[27]:
ItemID Rating
0 7 -9.281
1 8 -9.281
2 13 -6.781
3 15 0.875
4 16 -9.656
In [210]:
#always reset the index when you group by if you want to use the labels/indices 
#http://stackoverflow.com/questions/10373660/converting-a-pandas-groupby-object-to-dataframe
#pulling the avg joke rating for each ItemID and sorting in asc order
joke_group = df.groupby('ItemID').mean().sort('Rating').reset_index() 
joke_group.head(3)
Out[210]:
ItemID Rating
0 141 -2.749574
1 124 -2.163482
2 7 -1.809230
In [48]:
jester_jokes_descriptions = pandas.read_table('/Users/erikrood/anaconda/bin/jester_items.dat')
In [209]:
jester_jokes_descriptions.head(3)
#this was a mess... cleaned in Google Sheets and re-imported
Out[209]:
1:
0 <p>
1 A man visits the doctor. The doctor says, &quot;I have bad news for you. You have canc...
2 <br />
In [59]:
#importing the Sheets-cleaned csv
clean_jester_jokes = pandas.read_csv('/Users/erikrood/anaconda/bin/CleanJokes.csv') 
In [208]:
clean_jester_jokes.head(3) 
Out[208]:
ItemID Joke part1 part2 part3 part4 part5 part6 part7 part8 part9
0 1 J1 A man visits the doctor. The doctor says, "I have bad news for you. You have cancer an... The man replies, "Well, thank God I don't have cancer!" NaN NaN NaN NaN NaN NaN NaN
1 10 J10 Two cannibals are eating a clown. One turns to the other and says:<br /> "Does this taste funny to you?" NaN NaN NaN NaN NaN NaN NaN
2 100 J100 Q: Whats the difference between greeting a queen and greeting the President of the Uni... A: You only have to get on one knee to greet the queen. NaN NaN NaN NaN NaN NaN NaN
In [207]:
#setting up data frame for ratings by joke #
df1 = joke_group
df1.head(3)
Out[207]:
ItemID Rating
0 141 -2.749574
1 124 -2.163482
2 7 -1.809230
In [206]:
#setting up data frame for total joke contents (to be joined w/ df1)
df2 = clean_jester_jokes
df2.head(3)
Out[206]:
ItemID Joke part1 part2 part3 part4 part5 part6 part7 part8 part9
0 1 J1 A man visits the doctor. The doctor says, "I have bad news for you. You have cancer an... The man replies, "Well, thank God I don't have cancer!" NaN NaN NaN NaN NaN NaN NaN
1 10 J10 Two cannibals are eating a clown. One turns to the other and says:<br /> "Does this taste funny to you?" NaN NaN NaN NaN NaN NaN NaN
2 100 J100 Q: Whats the difference between greeting a queen and greeting the President of the Uni... A: You only have to get on one knee to greet the queen. NaN NaN NaN NaN NaN NaN NaN
In [82]:
#joining the rating for each joke onto the main joke dataset
s1 = df2.merge(df1, how='left', on="ItemID")
In [205]:
#previewing joined table
s1.head(3)
Out[205]:
ItemID Joke part1 part2 part3 part4 part5 part6 part7 part8 part9 Rating
2 100 J100 Q: Whats the difference between greeting a queen and greeting the President of the Uni... A: You only have to get on one knee to greet the queen. NaN NaN NaN NaN NaN NaN NaN 1.040899
3 101 J101 Did you hear about the Buddhist who refused Novocaine during a root canal? He wanted t... NaN NaN NaN NaN NaN NaN NaN NaN -0.243649
4 102 J102 A man escaped jail by digging a hole from his jail cell to the outside world. When fin... "I'm free, I'm free!" he shouted. <br /> "So what?" said a little girl. "I'm four." NaN NaN NaN NaN NaN NaN 1.159786
In [204]:
#removing rows with null values in the Rating column
s1 = s1[np.isfinite(s1['Rating'])]
In [256]:
#pulling in the 10 lowest rated jokes
bottom_10 = s1.sort('Rating').head(150)
bottom_10.head(150)
Out[256]:
ItemID Joke part1 part2 part3 part4 part5 part6 part7 part8 part9 Rating
47 141 J141 Jack Bauer can get McDonald's breakfast after 10:30. NaN NaN NaN NaN NaN NaN NaN NaN -2.749574
28 124 J124 Person 1: Hey, wanna hear a great knock-knock joke?<br /> NaN NaN NaN NaN NaN NaN NaN NaN -2.163482
117 7 J7 How many feminists does it take to screw in a light bulb?<br /> That's not funny. NaN NaN NaN NaN NaN NaN NaN -1.809230
95 5 J5 Q. What's O. J. Simpson's web address?<br /> A. Slash, slash, backslash, slash, slash, escape. NaN NaN NaN NaN NaN NaN NaN -1.759324
58 16 J16 Q. What is orange and sounds like a parrot?<br /> A. A carrot. NaN NaN NaN NaN NaN NaN NaN -1.587044
104 58 J58 How many teddy bears does it take to change a lightbulb?<br /> It takes only one teddy bear, but it takes a whole lot of lightbulbs. NaN NaN NaN NaN NaN NaN NaN -1.393346
56 15 J15 Q: What did the blind person say when given some matzah?<br /> A: Who the hell wrote this? NaN NaN NaN NaN NaN NaN NaN -1.377098
67 24 J24 What do you get when you run over a parakeet with a lawnmower?<br /> Shredded tweet. NaN NaN NaN NaN NaN NaN NaN -1.059193
89 44 J44 A horse walks into a bar. The bartender asks:<br /> "So, why the long face?" NaN NaN NaN NaN NaN NaN NaN -0.986643
123 75 J75 Q: Do you know the difference between an intelligent male and the Sasquatch?<br /> A: There have been actual reported sightings of the Sasquatch. NaN NaN NaN NaN NaN NaN NaN -0.858343
63 20 J20 What's the difference between a Macintosh and an Etch-a-Sketch?<br /> You don't have to shake the Mac to clear the screen. NaN NaN NaN NaN NaN NaN NaN -0.702828
128 8 J8 Q. Did you hear about the dyslexic devil worshiper?<br /> A. He sold his soul to Santa. NaN NaN NaN NaN NaN NaN NaN -0.672010
122 74 J74 Q: How many stalkers does it take to change a light bulb?<br /> A: Two. One to replace the bulb, and the other to watch it day and night. NaN NaN NaN NaN NaN NaN NaN -0.605946
34 13 J13 They asked the Japanese visitor if they have elections in his country.<br /> "Every morning," he answers. NaN NaN NaN NaN NaN NaN NaN -0.590224
103 57 J57 Why are there so many Jones's in the phone book?<br /> Because they all have phones. NaN NaN NaN NaN NaN NaN NaN -0.482477
97 51 J51 Did you hear that Clinton has announced that there is a new national bird?<br /> The spread eagle. NaN NaN NaN NaN NaN NaN NaN -0.447108
3 101 J101 Did you hear about the Buddhist who refused Novocaine during a root canal? He wanted t... NaN NaN NaN NaN NaN NaN NaN NaN -0.243649
27 123 J123 When most people claim to be "killing time", it's only an expression. When Chuck Norri... NaN NaN NaN NaN NaN NaN NaN NaN -0.234875
77 33 J33 What do you call an American in the finals of the world cup?<br /> "Hey beer man!" NaN NaN NaN NaN NaN NaN NaN -0.185865
60 18 J18 A dog walks into Western Union and asks the clerk to send a telegram. He fills out a f... The clerk says, "You can add another 'Bow wow' for the same price."<br /> The dog responded, "Now wouldn't that sound a little silly?" NaN NaN NaN NaN NaN NaN -0.123444
111 64 J64 What is the rallying cry of the International Dyslexic Pride movement?<br /> Dyslexics Untie! NaN NaN NaN NaN NaN NaN NaN -0.082142
114 67 J67 Once upon a time, two brooms fell in love and decided to get married. Before the cerem... "How is this possible?" he asked. "We've never swept together!" NaN NaN NaN NaN NaN NaN NaN -0.036304
86 41 J41 What does an atheist say during an orgasm?<br /> "Oh Darwin! Oh Darwin!" NaN NaN NaN NaN NaN NaN NaN 0.084136
98 52 J52 Q: What do Monica Lewinsky and Bob Dole have in common?<br /> A: They were both upset when Bill finished first. NaN NaN NaN NaN NaN NaN NaN 0.093198
81 37 J37 A Jewish young man was seeing a psychiatrist for an eating and sleeping disorder.<br /> "I am so obsessed with my mother...As soon as I go to sleep, I start dreaming, and eve... The psychiatrist replies, "What, just one piece of toast, for a big boy like you?" NaN NaN NaN NaN NaN NaN 0.158529
52 146 J146 America:<br /> 8:00 - Welcome to work!<br /> Japan:<br /> 8:00 - Are you already at work?<br /> Romania:<br /> 8:00 - Has anyone come to work?<br /> NaN NaN NaN 0.178280
134 85 J85 Q: How many presidents does it take to screw in a light bulb?<br /> A: It depends upon your definition of screwing a light bulb. NaN NaN NaN NaN NaN NaN NaN 0.280961
127 79 J79 Q: Ever wonder why the IRS calls it Form 1040?<br /> A: Because for every $50 that you earn, you get 10 and they get 40. NaN NaN NaN NaN NaN NaN NaN 0.297552
88 43 J43 Arnold Schwarzenegger and Sylvester Stallone are making a movie about the lives of the... Stallone says, "I want to be Mozart."<br /> Swartzeneger says, "In that case...I'll be Bach." NaN NaN NaN NaN NaN NaN 0.301355
101 55 J55 A woman has twins, and gives them up for adoption. One of them goes to a family in Egy... Her husband responds, "But they are twins--if you've seen Juan, you've seen Amal." NaN NaN NaN NaN NaN NaN NaN 0.450689
41 136 J136 A man went to apply for a job. After filling out all of his applications, he waited an... The employer read all his applications and said, "We have an opening for people like y... "Oh, great," he said. "What is it?"<br /> "It's called the door!" NaN NaN NaN NaN NaN 0.462678
46 140 J140 Chuck Norris' calendar goes straight from March 31st to April 2nd; no one fools Chuck ... NaN NaN NaN NaN NaN NaN NaN NaN 0.630230
59 17 J17 How many men does it take to screw in a light bulb?<br /> One. Men will screw anything. NaN NaN NaN NaN NaN NaN NaN 0.695951
78 34 J34 Out in the backwoods of some midwestern state, little Johnny arrives at school an hour... Teacher: "Why are you so late, John?"<br /> NaN NaN NaN NaN NaN NaN NaN 0.726362
36 131 J131 A guy had been feeling down for so long that he finally decided to seek the aid of a p... He went there, lay on the couch, spilled his guts then waited for the profound wisdom ... The psychiatrist asked me a few questions, took some notes then sat thinking in silenc... He looked up with an expression of delight and said, "I think your problem is low self... NaN NaN NaN NaN NaN 0.744706
61 19 J19 Q: If a person who speaks three languages is called "trilingual," and a person who spe... A: American! NaN NaN NaN NaN NaN NaN NaN 0.775039
5 103 J103 Nurse: Doctor, Doctor, there's an invisible man in the waiting room!<br /> Doctor: Well, go in there and tell him that I can't see him! NaN NaN NaN NaN NaN NaN NaN 0.813324
2 100 J100 Q: Whats the difference between greeting a queen and greeting the President of the Uni... A: You only have to get on one knee to greet the queen. NaN NaN NaN NaN NaN NaN NaN 1.040899
74 30 J30 Q: What's the difference between a lawyer and a plumber? <br /> A: A plumber works to unclog the system. NaN NaN NaN NaN NaN NaN NaN 1.050188
66 23 J23 Q: What is the Australian word for a boomerang that won't come back?<br /> A: A stick. NaN NaN NaN NaN NaN NaN NaN 1.082720
107 60 J60 What did the Buddhist say to the hot dog vendor?<br /> Make me one with everything. NaN NaN NaN NaN NaN NaN NaN 1.085989
119 71 J71 At a recent Sacramento PC Users Group meeting, a company was demonstrating its latest ... Just then, someone in the back of the room yelled, "Format C: Return."<br /> Someone else chimed in: "Yes, Return."<br /> Unfortunately, the software worked. NaN NaN NaN NaN NaN 1.090309
4 102 J102 A man escaped jail by digging a hole from his jail cell to the outside world. When fin... "I'm free, I'm free!" he shouted. <br /> "So what?" said a little girl. "I'm four." NaN NaN NaN NaN NaN NaN 1.159786
145 95 J95 Just a thought...<br /> Before criticizing someone, walk a mile in their shoes.<br /> Then, when you do criticize them, you will be a mile away and have their shoes! NaN NaN NaN NaN NaN NaN 1.196199
68 25 J25 Two kindergarten girls were talking outside: one said, "You won't believe what I saw o... The second girl asked, "What's a patio?" NaN NaN NaN NaN NaN NaN NaN 1.203699
131 82 J82 Q: How do you keep a computer programmer in the shower all day long?<br /> A: Give them a shampoo with a label that says "rinse, lather, repeat." NaN NaN NaN NaN NaN NaN NaN 1.254128
105 59 J59 The Chukcha (Russian Eskimo) phones up the Russian Parliament Building. A guard answer... Chukcha: "What is required to become Parliament member?"<br /> Guard: "What are you, an idiot?"<br /> Chukcha: "Is it required?" NaN NaN NaN NaN NaN 1.279296
65 22 J22 A duck walks into a pharmacy and asks for a condom. The pharmacist asks, "Would you li... "What kind of duck do you think I am!" NaN NaN NaN NaN NaN NaN NaN 1.285638
91 46 J46 A couple has been married for 75 years. For the husband's 95th birthday, his wife deci... A 21-year-old in a latex outfit smiles and says, "Hi, I here to give you super sex!"<b... The old man says, "I'll take the soup." NaN NaN NaN NaN NaN NaN 1.319228
16 113 J113 The new employee stood before the paper shredder looking confused.<br /> "Need some help?" a secretary asked.<br /> "Yes," he replied. "How does this thing work?"<br /> "Simple," she said, taking the fat report from his hand and feeding it into the shredd... "Thanks, but where do the copies come out?" NaN NaN NaN NaN 1.438138
38 133 J133 The new employee stood before the paper shredder looking confused. "Need some help?" a... "Thanks, but where do the copies come out?" NaN NaN NaN NaN NaN NaN NaN 1.443833
35 130 J130 An old man goes to the doctor for his yearly physical, his wife tagging along. When th... The old man, being hard of hearing, looks at his wife and yells: "WHAT? What did he sa... His wife yells back, "He needs your underwear." NaN NaN NaN NaN NaN NaN 1.470360
85 40 J40 How many Irishmen does it take to change a lightbulb?<br /> Two. One to hold the lightbulb and the other to drink until the room spins. NaN NaN NaN NaN NaN NaN NaN 1.515289
135 86 J86 A neutron walks into a bar and orders a drink. "How much do I owe you?" the neutron as... The bartender replies, "For you, no charge." NaN NaN NaN NaN NaN NaN NaN 1.520783
125 77 J77 If pro- is the opposite of con-, then congress must be the opposite of progress. NaN NaN NaN NaN NaN NaN NaN NaN 1.551565
90 45 J45 A boy comes home from school and tells his mother that he got a part in the school pla... "Go back to school and tell your teacher that you want a speaking role!" NaN NaN NaN NaN NaN NaN NaN 1.585176
44 139 J139 In a Veteran's Day speech, President Bush vowed, "We will finish the mission. Period."... NaN NaN NaN NaN NaN NaN NaN NaN 1.597179
87 42 J42 Two men are discussing the age old question: who enjoys sex more, the man or the woman... "Listen, you guys. You know when your ear itches and you put in your little finger and... NaN NaN NaN NaN NaN NaN NaN 1.597345
24 120 J120 Judy was having trouble with her computer, so she called Tony, the computer guy, over ... And he replied, "It was an ID Ten T Error."<br /> A puzzled expression ran riot over Judy's face. "An ID Ten T Error? What's that...in c... He gave her a grin..."Haven't you ever heard of an ID Ten T Error before?"<br /> "No," replied Judy.<br /> "Write it down," he said, "and I think you'll figure it out."<br /> (She wrote...) I D 1 0 T NaN NaN 1.616900
18 115 J115 A lady bought a new Lexus. It cost a bundle. Two days later, she brought it back, comp... "Madam," said the sales manager, "the audio system in this car is completely automatic... She drove out, somewhat amazed and a little confused. She looked at the radio and said... She was stopped at a traffic light enjoying "On the Road Again" when the light turned ... "Idiot!" she yelled and, from the radio, "Ladies and gentlemen, the President of the U... NaN NaN NaN NaN 1.627062
118 70 J70 Employer to applicant: "In this job we need someone who is responsible."<br /> Applicant: "I'm the one you want. On my last job, every time anything went wrong, they... NaN NaN NaN NaN NaN NaN NaN 1.687373
42 137 J137 Deep within a forest, a little turtle began to climb a tree. After hours of effort, he... Finally, the female bird turned to her mate. "Dear," she chirped, "I think it's time t... NaN NaN NaN NaN NaN NaN NaN 1.731473
140 90 J90 Q: How many programmers does it take to change a lightbulb?<br /> A: NONE! That's a hardware problem... NaN NaN NaN NaN NaN NaN NaN 1.734477
83 39 J39 What is the difference between men and women?<br /> A woman wants one man to satisfy her every need.<br /> NaN NaN NaN NaN NaN NaN NaN 1.737969
19 116 J116 A man in a hot air balloon realized he was lost. He reduced altitude and spotted a wom... He descended a bit more and shouted, "Excuse me, can you help me? I promised a friend ... The woman below replied, "You are in a hot air balloon hovering approximately 30 feet ... "You must be an engineer," said the balloonist.<br /> "I am," replied the woman. "How did you know?"<br /> "Well," answered the balloonist, "everything you told me is technically correct, but I... The woman below responded, "You must be in management."<br /> "I am," replied the balloonist, "but how did you know?" <br /> NaN 1.747193
121 73 J73 Q: What is the difference between George Washington, Richard Nixon, and Bill Clinton?<... A: Washington couldn't tell a lie, Nixon couldn't tell the truth, and Clinton doesn't ... NaN NaN NaN NaN NaN NaN NaN 1.754695
53 147 J147 It was the day of the big sale. Rumors of the sale (and some advertising in the local ... A small man pushed his way to the front of the line, only to be pushed back, amid loud... "That does it! If they hit me one more time, I won't open the store!" NaN NaN NaN NaN NaN NaN 1.783395
82 38 J38 "May I take your order?" the waiter asks.<br /> "Yes, how do you prepare your chickens?"<br /> "Nothing special, sir," he replies. "We just tell them straight out that they're going... NaN NaN NaN NaN NaN NaN 1.833548
50 144 J144 A man is driving in the country one evening when his car stalls and won't start. He go... As they are eating and chatting, he eventually asks the farmer why the pig is there an... NaN NaN NaN NaN NaN NaN NaN 1.868862
108 61 J61 During a recent publicity outing, Hillary sneaked off to visit a fortune teller of som... "There's no easy way to say this, so I'll just be blunt: Prepare yourself to be a wido... Visibly shaken, Hillary stared at the woman's lined face, then at the single flickerin... "Will I be acquitted?" NaN NaN NaN NaN NaN 1.891144
144 94 J94 Two atoms are walking down the street when one atom says to the other, "Oh, my! I've l... The second atom says, "Are you sure?"<br /> The first replies, "I'm positive!" NaN NaN NaN NaN NaN NaN 1.939941
149 99 J99 A bus station is where a bus stops.<br /> On my desk I have a work station... NaN NaN NaN NaN NaN NaN NaN 1.940483
40 135 J135 A guy walked past a mental hospital and heard a moaning voice: "13...13...13...13..."<... The man looked over to the hospital and saw a hole in the wall. He looked through the ... NaN NaN NaN NaN NaN NaN NaN 1.960949
141 91 J91 A Panda walks into a bar, sits down at a table and orders a beer and a double cheesebu... The bartender returns, pulls out his dictionary.<br /> panda: \Pan"da\, n. (Zo["o]l.)<br /> NaN NaN NaN NaN NaN NaN 1.963989
21 118 J118 A man goes into a drug store and asks the pharmacist if he can give him something for ... The pharmacist promptly reaches out and slaps the man's face. <br /> "What the heck did you do that for?!" the man screams. <br /> "Well, you don't have the hiccups anymore, do you?" <br /> The man says, "No I don't, you IDIOT...but my wife out in the car still does!" NaN NaN NaN NaN 1.983900
142 92 J92 Early one morning a mother went to her sleeping son and woke him up.<br /> "Wake up, son. It's time to go to school."<br /> "Give me two good reasons why I should go to school."<br /> "One, you are fifty-two years old. Two, you are the principal of the school." NaN NaN NaN NaN NaN 1.985816
48 142 J142 One day, three men went to a shrine to ask the Father for forgiveness.<br /> The first man went to the Father...<br /> First Man: "Father, Father, I have sinned!"<br /> And so the man drank the water and was "saved."<br /> The second man went up to the Father...<br /> Second Man: "Father, Father, I have sinned!"<br /> And so the second man drank the holy water and was "saved."<br /> The third man went up to the Father...<br /> NaN 2.003236
11 109 J109 "Do you believe in life after death?" the boss asked one of his employees.<br /> "Yes, sir," the new recruit replied. <br /> "Well, then, that makes everything just fine..." the boss went on. <br /> "After you left early yesterday to go to your grandmother's funeral, she stopped in to... NaN NaN NaN NaN NaN 2.087395
130 81 J81 An Asian man goes into a New York CityBank to exchange 10,000 yen for American Currenc... Whereupon the Asian man looks back at the teller and says "Fluk you Amelicans too!" NaN NaN NaN NaN NaN NaN NaN 2.105336
71 28 J28 A mechanical engineer, an electrical engineer, and a software engineer from Microsoft ... The mechanical engineer said: "It seems to be a problem with the fuel injection system... Then the software engineer from Microsoft jumps in. "No, no, no. If we just close up a... NaN NaN NaN NaN NaN NaN 2.151406
133 84 J84 Q: What is the difference between mechanical engineers and civil engineers?<br /> A: Mechanical Engineers build weapons, civil engineers build targets. NaN NaN NaN NaN NaN NaN NaN 2.152618
129 80 J80 Hillary, Bill Clinton and the Pope are sitting together on an airplane. Bill says, "I ... The Pope chips in and says, "I could throw Bill out of the airplane and make the whole... NaN NaN NaN NaN NaN NaN NaN 2.236964
148 98 J98 Age and Womanhood<br /> 1. Between the ages of 13 and 18...<br /> 2. Between the ages of 19 and 35...<br /> 3. Between the ages of 36 and 45...<br /> 4. Between the ages of 46 and 56...<br /> 5. After 56 she is like Australia...<br /> NaN NaN NaN 2.254257
15 112 J112 When my three-year-old son opened the birthday gift from his grandmother, he discovere... Mom smiled and then replied..."I remember." NaN NaN NaN NaN NaN NaN NaN 2.260055
126 78 J78 Q: What's the difference between the government and the Mafia?<br /> A: One of them is organized. NaN NaN NaN NaN NaN NaN NaN 2.268512
137 88 J88 A Czechoslovakian man felt his eyesight was growing steadily worse, and felt it was ti... The doctor started with some simple testing, and showed him a standard eye chart with ... "Can you read this?" the doctor asked.<br /> "Read it?" the Czech answered. "Doc, I know him!" NaN NaN NaN NaN NaN 2.307978
146 96 J96 Two attorneys went into a diner and ordered two drinks. Then they produced sandwiches ... The attorneys looked at each other, shrugged their shoulders and then exchanged sandwi... NaN NaN NaN NaN NaN NaN NaN 2.317811
25 121 J121 A drunk staggers into a Catholic Church, enters a confessional booth, sits down, but s... Finally, the Priest pounds three times on the wall.<br /> The drunk mumbles, "Ain't no use knockin, there's no paper on this side either." NaN NaN NaN NaN NaN NaN 2.370762
75 31 J31 President Clinton looks up from his desk in the Oval Office to see one of his aides ne... "What is it?" exclaims the President.<br /> "It's this Abortion Bill, Mr. President. What do you want to do about it?" the aide as... "Just go ahead and pay it," responds the President. NaN NaN NaN NaN NaN 2.372583
55 149 J149 A little girl asked her father, "Daddy? Do all fairy tales begin with 'Once Upon a Tim... He replied, "No, there is a whole series of fairy tales that begin with 'If elected I ... NaN NaN NaN NaN NaN NaN NaN 2.399796
136 87 J87 A man who recently completed a routine physical examination receives a phone call from... The doctor says, "The bad news is: I forgot to call you yesterday." NaN NaN NaN NaN NaN NaN NaN 2.412908
51 145 J145 A blonde, brunette, and a red head are all lined up to be shot to death by a firing sq... The brunette shouts, "Tornado!" and the riflemen turn around to see the tornado. It is... The red head yells, "Lightning!" and the riflemen again turn to see the disaster, yet ... The blonde yells, "Fire!"<br /> The riflemen do. NaN NaN NaN NaN 2.459413
132 83 J83 What a woman says: <br /> What a man hears: <br /> NaN NaN NaN NaN NaN NaN NaN 2.467828
102 56 J56 A man and Cindy Crawford get stranded on a desert island. After a couple of days they ... She says, "Hello, what's up?"<br /> He replies, "Bob, you won't believe it: I've been sleeping with Cindy Crawford for the... NaN NaN NaN NaN NaN NaN 2.489716
69 26 J26 A guy walks into a bar and sits down next to an extremely gorgeous woman. The first th... After several minutes of puzzling over how she got the pants up over her hips, he fina... "Well," she replied, "you can start by buying me a drink." NaN NaN NaN NaN NaN NaN 2.515811
112 65 J65 Two rednecks were seated at the end of a bar when a young lady seated a few stools up ... She was so shocked, she coughed up the obstruction and began to breathe--with great re... The redneck walked back to his friend and said, "Funny how that hind lick maneuver alw... NaN NaN NaN NaN NaN NaN 2.541904
26 122 J122 An astronomer, a physicist and a mathematician (it is said) were holidaying in Scotlan... "How interesting," observed the astronomer, "All Scottish sheep are black!"<br /> To which the physicist responded, "No, no! Some Scottish sheep are black!"<br /> The mathematician gazed heavenward in supplication, and then intoned, "In Scotland the... NaN NaN NaN NaN NaN 2.568692
9 107 J107 (A) The Japanese eat very little fat and suffer fewer heart attacks than the British o... (B) On the other hand, the French eat a lot of fat and also suffer fewer heart attacks... (C) The Chinese drink very little red wine and suffer fewer heart attacks than the Bri... (D) The Italians drink excessive amounts of red wine and also suffer fewer heart attac... (E) Conclusion: Eat and drink what you like. It's speaking English that kills you. NaN NaN NaN NaN 2.585653
32 128 J128 An American, a Scot and a Canadian were in a terrible car accident. They were all brou... Just as they were about to put the toe tag on the American, he stirred and opened his ... "Well," said the American, "I remember the crash, and then there was a beautiful light... "That's amazing!" said the one of the doctors, "But what happened to the other two?"<b... "Last I saw them," replied the American, "the Scot was haggling over the price and the... NaN NaN NaN NaN 2.589666
49 143 J143 A preist, a 12-year-old kid, and the smartest guy in the world are on a plane.<br /> The pilot screams, "The plane is going down! You have to jump!" He then grabs a parach... The smartest guy in the world says, "I have to go. I mean, I'm the smartest guy in the... The priest then looks at the 12-year-old kid, and says, "Go, my son. You have a long l... The kid calmly responds: "Dude, chill. We'll be fine. The 'smartest guy in the world' ... NaN NaN NaN NaN 2.719247
93 48 J48 The graduate with a Science degree asks, "Why does it work?"<br /> The graduate with an Engineering degree asks, "How does it work?"<br /> The graduate with an Accounting degree Asks, "How much will it cost?"<br /> The graduate with a Liberal Arts degree asks, "Do you want fries with that?" NaN NaN NaN NaN NaN 2.732436
13 110 J110 One day, a professor was giving a big test to his students. He handed out the tests an... The professor noticed that one of the students had attached a $100 bill to his test wi... The next class the professor handed the tests back out. This student got back his test... NaN NaN NaN NaN NaN NaN 2.771978
113 66 J66 A lawyer opened the door of his BMW, when suddenly a car came along and hit the door, ... "Officer, look what they've done to my Beeeeemer!" he whined.<br /> "You lawyers are so materialistic, you make me sick!" retorted the officer. "You're so... "Oh my gaaaad..." replied the lawyer, finally noticing the bloody left shoulder where ... NaN NaN NaN NaN NaN 2.793385
22 119 J119 One day the first grade teacher was reading the story of the Three Little Pigs to her ... The teacher paused then asked the class, "And what do you think that man said?" <br /> One little boy raised his hand and said, "I know...he said, 'Holy Shit! A talking pig!'" NaN NaN NaN NaN NaN NaN 2.798315
143 93 J93 Reaching the end of a job interview, the human resources person asked a young engineer... "And what starting salary were you looking for?"<br /> The engineer said, "In the neighborhood of $125,000 a year, depending on the benefits ... The interviewer said, "Well, what would you say to a package of 5-weeks vacation, 14 p... The engineer sat up straight and said, "Wow! Are you kidding?"<br /> And the interviewer replied, "Yeah, but you started it." NaN NaN NaN 2.798977
43 138 J138 WASHINGTON (Reuters) - A tragic fire on Monday destroyed the personal library of Presi... Presidential spokesman Ari Fleischer said the president was devastated, as he had not ... NaN NaN NaN NaN NaN NaN NaN 2.800066
14 111 J111 A new business was opening and one of the owner's friends wanted to send him flowers f... The owner was angry and called the florist to complain.<br /> After he had told the florist of the obvious mistake and how angry he was, the florist... NaN NaN NaN NaN NaN NaN 2.801907
57 150 J150 In an interview with David Letterman, Carter passed along an anecdote of a translation... He told the joke, then waited for the translator to announce the Japanese version. Eve... After the speech, Carter wanted to meet the translator to ask him how he told the joke... When Carter asked how the joke had been told in Japanese, the translator responded, "I... NaN NaN NaN NaN NaN 2.810758
29 125 J125 An American tourist goes into a restaurant in Spain and orders the specialty of the ho... "These, senor," replied the waiter in broken English, "are the testicles of the bull k... The tourist swallowed hard but tasted the dish and thought it was delicious. So he com... "Yes, senor," replied the waiter, "You see...the bull, he does not always lose. NaN NaN NaN NaN NaN 2.820728
147 97 J97 A teacher is explaining to her class how different languages use negatives differently... One of the students puts up his hand and says, "Yeah, right." NaN NaN NaN NaN NaN NaN NaN 2.907676
124 76 J76 There once was a man and a woman that both got in a terrible car wreck. Both of their ... NaN NaN NaN NaN NaN NaN NaN NaN 2.922643
80 36 J36 A guy walks into a bar, orders a beer and says to the bartender, "Hey, I got this grea... The barkeep glares at him and says in a warning tone of voice: "Before you go telling ... "Okay," says the customer. "I'll tell it very slowly." NaN NaN NaN NaN NaN NaN 2.924463
70 27 J27 Bill Clinton returns from a vacation in Arkansas and walks down the steps of Air Force... The guardsman replies, "Nice trade, Sir." NaN NaN NaN NaN NaN NaN NaN 2.933842
100 54 J54 The Pope dies and, naturally, goes to heaven. He's met by the reception committee, and... He decides that he wants to read all of the ancient original text of the Holy Scriptur... All of a sudden there is a scream in the library. The angels come running in only to f... After collecting his wits, the Pope sobs again, "It's the letter 'R'. They left out th... NaN NaN NaN NaN NaN 2.948808
64 21 J21 What's the difference between a used tire and 365 used condoms?<br /> One's a Goodyear, the other's a great year. NaN NaN NaN NaN NaN NaN NaN 2.987422
92 47 J47 There was an engineer who had an exceptional gift for fixing all things mechanical. Af... The engineer reluctantly took the challenge. He spent a day studying the huge machine.... "This is where your problem is."<br /> The part was replaced and the machine worked perfectly again. The company received a b... One chalk mark: $1.<br /> Knowing where to put it: $49,999.<br /> He was paid in full and the engineer retired again in peace. NaN NaN 2.988006
110 63 J63 An engineer, a physicist and a mathematician are sleeping in a room. There is a fire i... Again there is a fire in the room. This time, the physicist wakes up, notices the buck... Again there is a fire. This time the mathematician wakes up. He looks at the fire, loo... NaN NaN NaN NaN NaN NaN 2.995237
72 29 J29 An old Scotsman is sitting with a younger Scottish gentleman and says to the boy, "Ah,... He takes a few sips of his beer then says, "Aye, and look out on that lake and eye tha... He continues: "And lad, you see that road? That too I build with me own bare hands. La... Again he returns to his beer for a few sips, and then says, "Agh, but you screw one sh... NaN NaN NaN NaN NaN 3.046279
54 148 J148 Recently a teacher, a garbage collector, and a lawyer wound up together at the Pearly ... St. Peter addressed the teacher and asked, "What was the name of the ship that crashed... The teacher answered quickly, "That would be the Titanic." St. Peter let him through t... St. Peter turned to the garbage man and, figuring Heaven didn't really need all the od... Fortunately for him, the trash man had just seen the movie. "1,228," he answered. <br /> "That's right! You may enter."<br /> St. Peter turned to the lawyer: "Name them." NaN NaN 3.061760
94 49 J49 Three engineering students were gathered together discussing the possible designers of... One said, "It was a mechanical engineer. Just look at all the joints."<br /> Another said, "No, it was an electrical engineer. The nervous systems many thousands o... The last said, "Actually, it was a civil engineer. Who else would run a toxic waste pi... NaN NaN NaN NaN NaN 3.089760
39 134 J134 An artist asked the gallery owner if there had been any interest in his paintings curr... "That's wonderful!" the artist exclaimed. "What's the bad news?"<br /> With concern, the gallery owner replied:"The guy was your doctor." NaN NaN NaN NaN NaN NaN 3.174906
31 127 J127 A little boy goes to his dad and asks, "What is politics?"<br /> His dad says, "Well son, let me try to explain it this way: I'm the breadwinner of the... So the little boy goes off to bed thinking about what dad had said. Later that night, ... The little boy replies, "Well, while capitalism is screwing the working class, the gov... NaN NaN NaN NaN NaN 3.175006
30 126 J126 A Briton, a Frenchman and a Russian are viewing a painting of Adam and Eve frolicking ... "Nonsense," the Frenchman disagrees. "They're naked, and so beautiful. Clearly, they a... "No way! They have no clothes and no shelter," the Russian points out, "They have only... NaN NaN NaN NaN NaN NaN 3.186807
17 114 J114 Sherlock Holmes and Dr. Watson go on a camping trip, set up their tent, and fall aslee... Watson replies, "I see millions of stars." <br /> "What does that tell you?" <br /> Watson ponders for a minute. "Astronomically speaking, it tells me that there are mill... Holmes is silent for a moment, then speaks. "Watson, you idiot, someone has stolen our... NaN NaN NaN NaN 3.192799
20 117 J117 A man joins a big corporate empire as a trainee.<br /> On his very first day of work, he dials the pantry and shouts into the phone: "Get me ... The voice from the other side responds, "You fool, you've dialed the wrong extension! ... "No," replied the trainee.<br /> The trainee shouts back, "And do YOU know who YOU are talking to, you fool?!"<br /> "Good!" replied the trainee, and puts down the phone. NaN NaN NaN 3.212523
37 132 J132 Mickey Mouse is having a nasty divorce with Minnie Mouse. Mickey spoke to the judge ab... "I'm sorry Mickey, but I can't legally separate you two on the grounds that Minnie is ... Mickey replied, "I didn't say she was mentally insane, I said that she's fucking Goofy!" NaN NaN NaN NaN NaN NaN 3.248195
116 69 J69 This guy's wife asks, "Honey, if I died would you remarry?" and he replies, "Well, aft... She then asks, "If I died and you remarried, would she live in this house?" and he rep... "If I died and you remarried, and she lived in this house, would she sleep in our bed?... So she asks, "If I died and you remarried, and she lived in this house, and slept in o... "Oh no, she's left handed." NaN NaN NaN NaN 3.250073
10 108 J108 A man approached a very beautiful woman in a large supermarket and asked, "You know, I... "Why?" <br /> "Because every time I talk to a beautiful woman my wife appears out of nowhere." NaN NaN NaN NaN NaN NaN 3.260469
96 50 J50 A guy goes into confession and says to the priest, "Father, I'm 80 years old, widower,... The priest says, "Well, my son, when was the last time you were in confession?"<br /> "Never Father, I'm Jewish."<br /> "So then, why are you telling me?"<br /> "I'm telling everybody!" NaN NaN NaN NaN 3.273923
109 62 J62 A group of managers were given the assignment to measure the height of a flagpole. So ... After the engineer has gone, one manager turns to another and laughs. "Isn't that just... NaN NaN NaN NaN NaN NaN NaN 3.310934
8 106 J106 An engineer dies and reports to the pearly gates. St. Peter checks his dossier and say... Satan replies, "Hey, things are going great. We've got air conditioning, flush toilets... God replies, "What?? You've got an engineer? That's a mistake--he should never have go... Satan says, "No way." I like having an engineer on the staff, and I'm keeping him."<br /> God says, "Send him back up here or I'll sue."<br /> Satan laughs uproariously and answers, "Yeah, right. And just where are YOU going to g... NaN NaN NaN 3.337933
115 68 J68 A man piloting a hot air balloon discovers he has wandered off course and is hopelessl... The man below says, "Yes, you're in a hot air balloon, about 30 feet above this field.... "You must work in Information Technology," says the balloonist.<br /> "Yes I do," replies the man. "And how did you know that?"<br /> "Well," says the balloonist, "what you told me is technically correct, but of no use t... The man below says, "You must work in management."<br /> "I do," replies the balloonist, "how did you know?"<br /> "Well," says the man, "you don't know where you are, or where you're going, but you ex... NaN 3.387269
6 104 J104 As a pre-med student, I had to take a difficult class in physics. One day our professo... "To save lives." The professor responded quickly and continued the lecture.<br /> A few minutes later, the same student spoke up again. "So how does physics save lives?... "It usually keeps the idiots like you out of medical school," replied the professor. NaN NaN NaN NaN NaN 3.422796
76 32 J32 A man arrives at the gates of heaven. St. Peter asks, "Religion?" The man says, "Metho... Another man arrives at the gates of heaven. "Religion?" "Baptist." "Go to room 18, but... A third man arrives at the gates. "Religion?" "Jewish." "Go to room 11, but be very qu... NaN NaN NaN NaN NaN NaN 3.504739
120 72 J72 On the first day of college, the Dean addressed the students, pointing out some of the... At this point, a male student in the crowd inquired: "How much for a season pass?" NaN NaN NaN NaN NaN NaN NaN 3.505712
79 35 J35 An explorer in the deepest Amazon suddenly finds himself surrounded by a bloodthirsty ... The sky darkens and a voice booms out, "No, you are NOT screwed. Pick up that stone at... So with the stone he bashes the life out of the chief. He stands above the lifeless bo... The voice booms out again, "Okay....NOW you're screwed." NaN NaN NaN NaN NaN 3.560305
33 129 J129 A group of girlfriends is on vacation when they see a 5-story hotel with a sign that r... The bouncer, a very attractive guy, explains to them how it works. "We have 5 floors. ... So they start going up and on the first floor the sign reads: "All the men on this flo... The sign on the second floor reads: "All the men here are short and handsome." Still, ... They reach the third floor and the sign reads: "All the men here are tall and plain." ... They still want to do better, and so, knowing there are still two floors left, they co... On the fourth floor, the sign is perfect: "All the men here are tall and handsome." Th... There they find a sign that reads: "There are no men here. This floor was built only t... NaN 3.583496
138 89 J89 A radio conversation between a US naval ship and Canadian authorities...<br /> Americans: Please divert your course 15 degrees to the North to avoid a collision.<br /> Canadians: Recommend you divert YOUR course 15 degrees to the South to avoid a collisi... Americans: This is the captain of a US Navy ship. I say again, divert YOUR course.<br /> Canadians: No. I say again, you divert YOUR course.<br /> Americans: This is the aircraft carrier USS Lincoln, the second largest ship in the Un... Canadians: This is a lighthouse. Your call. NaN NaN 3.606506
7 105 J105 A couple of hunters are out in the woods in the deep south when one of them falls to t... The other guy whips out his cell phone and calls 911. He gasps to the operator, "My fr... The operator, in a calm and soothing voice, says, "Alright, take it easy. I can help. ... There is silence, and then a gun shot is heard.<br /> The hunter comes back on the line. "Okay. Now what??" NaN NaN NaN NaN 3.711223
99 53 J53 One Sunday morning William burst into the living room and said, "Dad! Mom! I have some... After dinner, William's dad took him aside. "Son, I have to talk with you. Your mother... William was heart-broken. After eight months he eventually started dating girls again.... Again his father insisted on another private conversation and broke the sad news. "Dia... William was furious! He finally decided to go to his mother with the news.<br /> "Dad has done so much harm.. I guess I'm never going to get married," he complained. "... His mother just shook her head. "Don't pay any attention to what he says, dear. He's n... NaN NaN 3.714381
In [253]:
#pulling in the 10 highest rated jokes
top_10 = s1.sort('Rating').tail(10)
top_10.head(150)
Out[253]:
ItemID Joke part1 part2 part3 part4 part5 part6 part7 part8 part9 Rating
8 106 J106 An engineer dies and reports to the pearly gates. St. Peter checks his dossier and say... Satan replies, "Hey, things are going great. We've got air conditioning, flush toilets... God replies, "What?? You've got an engineer? That's a mistake--he should never have go... Satan says, "No way." I like having an engineer on the staff, and I'm keeping him."<br /> God says, "Send him back up here or I'll sue."<br /> Satan laughs uproariously and answers, "Yeah, right. And just where are YOU going to g... NaN NaN NaN 3.337933
115 68 J68 A man piloting a hot air balloon discovers he has wandered off course and is hopelessl... The man below says, "Yes, you're in a hot air balloon, about 30 feet above this field.... "You must work in Information Technology," says the balloonist.<br /> "Yes I do," replies the man. "And how did you know that?"<br /> "Well," says the balloonist, "what you told me is technically correct, but of no use t... The man below says, "You must work in management."<br /> "I do," replies the balloonist, "how did you know?"<br /> "Well," says the man, "you don't know where you are, or where you're going, but you ex... NaN 3.387269
6 104 J104 As a pre-med student, I had to take a difficult class in physics. One day our professo... "To save lives." The professor responded quickly and continued the lecture.<br /> A few minutes later, the same student spoke up again. "So how does physics save lives?... "It usually keeps the idiots like you out of medical school," replied the professor. NaN NaN NaN NaN NaN 3.422796
76 32 J32 A man arrives at the gates of heaven. St. Peter asks, "Religion?" The man says, "Metho... Another man arrives at the gates of heaven. "Religion?" "Baptist." "Go to room 18, but... A third man arrives at the gates. "Religion?" "Jewish." "Go to room 11, but be very qu... NaN NaN NaN NaN NaN NaN 3.504739
120 72 J72 On the first day of college, the Dean addressed the students, pointing out some of the... At this point, a male student in the crowd inquired: "How much for a season pass?" NaN NaN NaN NaN NaN NaN NaN 3.505712
79 35 J35 An explorer in the deepest Amazon suddenly finds himself surrounded by a bloodthirsty ... The sky darkens and a voice booms out, "No, you are NOT screwed. Pick up that stone at... So with the stone he bashes the life out of the chief. He stands above the lifeless bo... The voice booms out again, "Okay....NOW you're screwed." NaN NaN NaN NaN NaN 3.560305
33 129 J129 A group of girlfriends is on vacation when they see a 5-story hotel with a sign that r... The bouncer, a very attractive guy, explains to them how it works. "We have 5 floors. ... So they start going up and on the first floor the sign reads: "All the men on this flo... The sign on the second floor reads: "All the men here are short and handsome." Still, ... They reach the third floor and the sign reads: "All the men here are tall and plain." ... They still want to do better, and so, knowing there are still two floors left, they co... On the fourth floor, the sign is perfect: "All the men here are tall and handsome." Th... There they find a sign that reads: "There are no men here. This floor was built only t... NaN 3.583496
138 89 J89 A radio conversation between a US naval ship and Canadian authorities...<br /> Americans: Please divert your course 15 degrees to the North to avoid a collision.<br /> Canadians: Recommend you divert YOUR course 15 degrees to the South to avoid a collisi... Americans: This is the captain of a US Navy ship. I say again, divert YOUR course.<br /> Canadians: No. I say again, you divert YOUR course.<br /> Americans: This is the aircraft carrier USS Lincoln, the second largest ship in the Un... Canadians: This is a lighthouse. Your call. NaN NaN 3.606506
7 105 J105 A couple of hunters are out in the woods in the deep south when one of them falls to t... The other guy whips out his cell phone and calls 911. He gasps to the operator, "My fr... The operator, in a calm and soothing voice, says, "Alright, take it easy. I can help. ... There is silence, and then a gun shot is heard.<br /> The hunter comes back on the line. "Okay. Now what??" NaN NaN NaN NaN 3.711223
99 53 J53 One Sunday morning William burst into the living room and said, "Dad! Mom! I have some... After dinner, William's dad took him aside. "Son, I have to talk with you. Your mother... William was heart-broken. After eight months he eventually started dating girls again.... Again his father insisted on another private conversation and broke the sad news. "Dia... William was furious! He finally decided to go to his mother with the news.<br /> "Dad has done so much harm.. I guess I'm never going to get married," he complained. "... His mother just shook her head. "Don't pay any attention to what he says, dear. He's n... NaN NaN 3.714381
In [122]:
#statistics about the n-count of parts, not used
count_nan = len(s1)-s1.count()
In [177]:
#function to count the number of non-null values in a given row...
#used to get n-count of parts of jokes
s3 = s1.iloc[:,2:10].apply(lambda s: (s > 0).sum(), axis=1)
s3.head()
Out[177]:
2    2
3    1
4    3
5    2
6    4
dtype: int64
In [188]:
#creating a table containing the number of parts in each joke
s4 = pandas.DataFrame(s3,columns = ['PartCount'])
In [252]:
#adding column called ItemID to match current index,
#allowing a left join to occur on main table
s4['ItemID'] = s4.index
s4.head(5)
Out[252]:
PartCount ItemID
2 2 2
3 1 3
4 3 4
5 2 5
6 4 6
In [198]:
#merging the s4 table containing part count onto main table
s5 = pandas.merge(s1, s4, left_index=True, right_index=True, how='inner')
In [200]:
s5.head(5)
Out[200]:
ItemID_x Joke part1 part2 part3 part4 part5 part6 part7 part8 part9 Rating PartCount ItemID_y
2 100 J100 Q: Whats the difference between greeting a queen and greeting the President of the Uni... A: You only have to get on one knee to greet the queen. NaN NaN NaN NaN NaN NaN NaN 1.040899 2 2
3 101 J101 Did you hear about the Buddhist who refused Novocaine during a root canal? He wanted t... NaN NaN NaN NaN NaN NaN NaN NaN -0.243649 1 3
4 102 J102 A man escaped jail by digging a hole from his jail cell to the outside world. When fin... "I'm free, I'm free!" he shouted. <br /> "So what?" said a little girl. "I'm four." NaN NaN NaN NaN NaN NaN 1.159786 3 4
5 103 J103 Nurse: Doctor, Doctor, there's an invisible man in the waiting room!<br /> Doctor: Well, go in there and tell him that I can't see him! NaN NaN NaN NaN NaN NaN NaN 0.813324 2 5
6 104 J104 As a pre-med student, I had to take a difficult class in physics. One day our professo... "To save lives." The professor responded quickly and continued the lecture.<br /> A few minutes later, the same student spoke up again. "So how does physics save lives?... "It usually keeps the idiots like you out of medical school," replied the professor. NaN NaN NaN NaN NaN 3.422796 4 6
In [221]:
s6 = s5[[11,12]] #creating subtable of rating and part count for scatterplot
In [1]:
#Creating scatterplot of PartCount vs. Rating

_x = s5['PartCount']
_y = s5['Rating']

# Create a trace
trace = go.Scatter(
    x = _x,
    y = _y,
    mode = 'markers'
)

data = [trace]
layout = go.Layout(
    title='Joke rating vs. number of parts (exponential)',
    hovermode='closest',
    xaxis=dict(
        title='Number of parts in joke (line breaks)',
        ticklen=5,
        zeroline=False,
        gridwidth=2,
    ),
    yaxis=dict(
        title='Joke Rating [Scale of -10 to +10]',
        ticklen=5,
        gridwidth=2,
    ))


# Plot and embed in ipython notebook
fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='basic-scatter2')
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-cf938b52bf3a> in <module>()
      1 #Creating scatterplot of PartCount vs. Rating
      2 
----> 3 _x = s5['PartCount']
      4 _y = s5['Rating']
      5 

NameError: name 's5' is not defined
In [249]:
#Creating a histogram of joke ratings

x = s5['Rating']
data = [
    go.Histogram(
        x=x
    )
]

layout = go.Layout(
    title='Histogram of Joke Ratings',
    xaxis=dict(
        title='Rating [from -10 to +10]'
    ),
    yaxis=dict(
        title='n-count'
    ))

fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='basic-histogram')
Out[249]:
In [ ]:
#hosting content on nbviewer 1- upload .pynb file to github, 2- view raw version of file, 
#3- upload raw url into nbviewer