In [47]:
import pandas as pd
from textblob import TextBlob

In [76]:
listings = pd.read_csv('listings.csv')
listings


Out[76]:
id name host_id host_name neighbourhood_group neighbourhood latitude longitude room_type price minimum_nights number_of_reviews last_review reviews_per_month calculated_host_listings_count availability_365
0 9132704 Living Room in apartment North York 47567573 Chelson NaN York University Heights 43.762057 -79.499867 Private room 30 1 2 2016-01-31 0.12 1 0
1 6832028 (4) Cozy Room near York University Toronto 24346665 Shanny NaN York University Heights 43.769069 -79.499139 Private room 39 2 10 2017-04-14 0.45 8 272
2 14596547 Private room beside york uni 44098156 Jay NaN York University Heights 43.767794 -79.501396 Private room 50 1 3 2017-05-18 0.32 5 365
3 8235594 2 Bed + Den, 2 Bath TOWNHOUSE with ROOFTOP #00026 12742095 Emil & Heather NaN York University Heights 43.765480 -79.496712 Entire home/apt 178 2 5 2017-04-04 0.31 23 365
4 9052835 Furnished Apartment Toronto 47232657 S M Fawaad NaN York University Heights 43.765558 -79.504300 Entire home/apt 45 1 0 NaN NaN 1 0
5 10772078 Sweet Home---Entire One Bedroom Apt (Walkout B... 45436801 Wendy NaN York University Heights 43.764802 -79.491673 Entire home/apt 35 2 12 2017-05-19 2.34 1 10
6 15888115 1 bedroom and office appartment at Subway station 103039584 Ella NaN York University Heights 43.750819 -79.465304 Entire home/apt 59 2 5 2017-05-31 0.91 1 2
7 9842943 Cozy and convenient - with parking! 50683042 Margaret NaN York University Heights 43.750327 -79.464908 Entire home/apt 70 3 1 2015-12-27 0.06 1 0
8 15790625 Cozy Condo Near Subway and Major Highways 102150863 Tara NaN York University Heights 43.752664 -79.465920 Entire home/apt 99 2 7 2017-02-15 1.11 1 0
9 8238835 Cozy Bedroom + Ensuite @ York University, Toronto 30753730 Jeishan NaN York University Heights 43.768740 -79.502254 Private room 39 2 17 2017-05-19 0.81 5 307
10 18415023 Room at York U for 7 days up 43488381 Runying NaN York University Heights 43.766246 -79.504329 Private room 28 1 3 2017-05-31 3.00 10 345
11 5923285 Snug BR @ York University, Toronto 30753730 Jeishan NaN York University Heights 43.768397 -79.500807 Private room 41 2 11 2017-05-31 0.42 5 14
12 18700196 Room at York U for 7 days up 43488381 Runying NaN York University Heights 43.767022 -79.496250 Private room 38 1 4 2017-05-29 4.00 10 338
13 18707265 Cozy Room For Couples/Singles 130051102 Nnamdi NaN York University Heights 43.768268 -79.503959 Private room 41 1 0 NaN NaN 1 85
14 13007164 Private Suite york 44098156 Jay NaN York University Heights 43.768184 -79.501235 Private room 45 1 19 2017-05-27 1.55 5 82
15 9250114 Family hotell , York University 44619526 Sigang NaN York University Heights 43.769611 -79.501000 Private room 26 5 0 NaN NaN 3 63
16 18477472 Private simple room 121230803 Dogan NaN York University Heights 43.758263 -79.492206 Private room 35 3 2 2017-05-17 2.00 2 365
17 18132114 Tidy one bedroom in North York 116976001 Dale NaN York University Heights 43.743885 -79.491791 Private room 30 1 0 NaN NaN 1 88
18 18240871 Room at York U for 7 days up 43488381 Runying NaN York University Heights 43.766035 -79.502877 Private room 36 1 4 2017-06-01 2.93 10 294
19 18931296 Room at York U for 7 days up 43488381 Runying NaN York University Heights 43.767351 -79.503013 Private room 32 1 0 NaN NaN 10 345
20 4934960 Beautiful cozy room in condo 22760672 Berna NaN York University Heights 43.752623 -79.465478 Private room 50 2 0 NaN NaN 1 288
21 12836532 Nice Private Room in north york. 44098156 Jay NaN York University Heights 43.768039 -79.501268 Private room 39 1 16 2017-05-02 1.24 5 354
22 4747093 Light and Airy, Clean Uptown Room 2226351 Simona NaN York University Heights 43.751310 -79.463360 Private room 41 2 0 NaN NaN 1 0
23 18931153 Room at York U for 7 days up 43488381 Runying NaN York University Heights 43.766417 -79.504567 Private room 28 1 0 NaN NaN 10 363
24 16272130 Room at York U rent 7 days Up 43488381 Runying NaN York University Heights 43.767765 -79.503029 Private room 32 1 1 2017-04-29 0.83 10 365
25 9250900 family hotel beside York University, close Fin 44619526 Sigang NaN York University Heights 43.769207 -79.500015 Shared room 26 4 0 NaN NaN 3 340
26 18691217 Cheap & comfy sofa beds in North York 125233646 Maja NaN York University Heights 43.763862 -79.504696 Shared room 27 2 2 2017-05-31 2.00 1 316
27 17763478 Master Bedroom near York University for clean ... 121230803 Dogan NaN York University Heights 43.758901 -79.492484 Private room 50 7 1 2017-04-30 0.86 2 279
28 1182952 Cozy Room close to York University 6471063 Maria Clemencia NaN York University Heights 43.765992 -79.499318 Private room 108 3 0 NaN NaN 1 89
29 6849449 (7) Bright room with balcony @ York Uni Toronto 24346665 Shanny NaN York University Heights 43.770559 -79.499899 Private room 39 2 4 2017-04-14 0.30 8 162
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
12684 18343535 Private Entry Cozy Basement Close to Subway 126933386 Rodica NaN Briar Hill-Belgravia 43.703337 -79.443237 Entire home/apt 65 1 0 NaN NaN 1 66
12685 9003758 Toronto great and cozy apartment 12838611 Samanta NaN Briar Hill-Belgravia 43.703525 -79.441619 Entire home/apt 51 15 0 NaN NaN 1 0
12686 16113559 MidTown Charm, Eglington W.Subway Private Wash... 53554718 Shalom NaN Briar Hill-Belgravia 43.699100 -79.448181 Private room 35 1 2 2017-03-01 0.34 3 28
12687 9495542 Basement near transit with kitchen 48258166 Feela NaN Briar Hill-Belgravia 43.698988 -79.445600 Private room 30 1 10 2017-04-30 0.64 2 45
12688 23691 Queen Bedroom close to downtown 93825 Yohan & Sarah NaN Briar Hill-Belgravia 43.696017 -79.454683 Private room 55 30 191 2016-11-27 2.24 2 0
12689 18569784 Private Room in Midtown Toronto 99918623 Rıza NaN Briar Hill-Belgravia 43.696891 -79.453625 Private room 26 2 0 NaN NaN 2 309
12690 18504548 Stunning Apartment in Brand New Modern Home 2853930 Aaron NaN Briar Hill-Belgravia 43.699241 -79.441444 Entire home/apt 80 2 1 2017-05-21 1.00 2 308
12691 9918337 Midtown Toronto2 Homestay-2004 50203566 Imelda NaN Briar Hill-Belgravia 43.703311 -79.439338 Shared room 36 4 4 2017-01-09 0.28 2 269
12692 9295152 Room near subway free parking. 48258166 Feela NaN Briar Hill-Belgravia 43.698988 -79.445034 Private room 30 2 6 2016-08-31 0.31 2 306
12693 15815021 Daytime free parking till 4.AM close to Downtown 92641156 Saifudeen NaN Briar Hill-Belgravia 43.704992 -79.441106 Private room 41 2 0 NaN NaN 2 179
12694 4066081 ONE BEDROOM CLOSE TO DOWNTOWN 20474972 Rosemary NaN Briar Hill-Belgravia 43.702642 -79.447265 Private room 59 3 27 2016-08-16 0.98 2 4
12695 15550265 Cozy & Comfortable Room in Midtown 92641156 Saifudeen NaN Briar Hill-Belgravia 43.704065 -79.440922 Private room 35 1 0 NaN NaN 2 364
12696 7651021 Cozy bungalow in mid. town Toronto 40147858 Tatiana NaN Briar Hill-Belgravia 43.698764 -79.441261 Entire home/apt 100 1 21 2017-05-27 0.94 1 245
12697 89575 Private bedroom close to downtown 93825 Yohan & Sarah NaN Briar Hill-Belgravia 43.696616 -79.453250 Private room 50 1 68 2016-11-26 1.01 2 153
12698 12324764 Private room in luxurious 2bdr apt 12553608 Fernanda NaN Briar Hill-Belgravia 43.704813 -79.443626 Private room 50 1 0 NaN NaN 1 365
12699 7089924 Grande chambre propre a Toronto 17248238 Ngalula NaN Briar Hill-Belgravia 43.693063 -79.462182 Private room 59 1 0 NaN NaN 1 0
12700 3950407 ONE BEDROOM CLOSE TO DOWNTOWN 2 20474972 Rosemary NaN Briar Hill-Belgravia 43.701565 -79.448272 Private room 55 2 22 2017-04-13 0.88 2 307
12701 6424363 Beautiful 1 b-room apt next 2 metro 9212719 AlexandToma NaN Briar Hill-Belgravia 43.704986 -79.439797 Entire home/apt 50 7 0 NaN NaN 1 0
12702 18836225 julie 131179480 Julie NaN Newtonbrook West 43.800734 -79.424440 Private room 85 1 1 2017-05-29 1.00 1 365
12703 18681852 Cute Cozy Room for Solo Traveler 128590833 Lisa NaN Steeles 43.824369 -79.309472 Private room 31 1 0 NaN NaN 4 90
12704 18755338 Modern Walk Out Basement 86556684 Nahid NaN Newtonbrook East 43.801579 -79.404881 Entire home/apt 80 3 0 NaN NaN 2 333
12705 18910252 home sweet home 131790324 Tony NaN Westminster-Branson 43.791676 -79.465651 Private room 50 1 0 NaN NaN 1 178
12706 18596938 北约克旺市交界家庭旅馆 128996717 Junfang NaN Westminster-Branson 43.793179 -79.451815 Private room 59 3 0 NaN NaN 2 179
12707 18579702 steeles/bathurst 多伦多万锦旺市交界家庭旅馆 128996717 Junfang NaN Westminster-Branson 43.794220 -79.453272 Private room 85 3 1 2017-05-07 1.00 2 90
12708 18932160 Family home in Toronto near Pacific Mall太古家庭旅馆... 131857038 Kathy NaN Steeles 43.823652 -79.307612 Private room 200 1 0 NaN NaN 4 26
12709 18890201 Private Room, mins away from Pacific Mall 110385144 Brian NaN Steeles 43.825190 -79.311550 Private room 20 1 0 NaN NaN 1 310
12710 18550498 Luxurious 1+1 BDR Condo (Free parking) 54422135 Afi NaN Newtonbrook West 43.795373 -79.438510 Entire home/apt 119 1 0 NaN NaN 6 352
12711 18827315 Luxury Five Star 2 Bedroom Condo 42944092 Zameer NaN Newtonbrook East 43.802197 -79.419981 Entire home/apt 142 1 0 NaN NaN 1 327
12712 18886780 2 bedroom Condo 86556684 Nahid NaN Newtonbrook East 43.801385 -79.421115 Entire home/apt 80 5 0 NaN NaN 2 205
12713 17592921 Private Bed and Bath Close to Toronto Airport 119541668 Danny NaN Markland Wood 43.632059 -79.590445 Private room 55 1 1 2017-05-28 1.00 1 78

12714 rows × 16 columns


In [146]:
l = {}
for i in listings.neighbourhood.unique():
    l[i] = (0.0,0)
    
print(l)


{'Beechborough-Greenbrook': (0.0, 0), 'Stonegate-Queensway': (0.0, 0), 'Palmerston-Little Italy': (0.0, 0), 'Lansing-Westgate': (0.0, 0), 'Regent Park': (0.0, 0), 'Henry Farm': (0.0, 0), 'Eglinton East': (0.0, 0), 'New Toronto': (0.0, 0), 'Woodbine-Lumsden': (0.0, 0), 'Westminster-Branson': (0.0, 0), 'Caledonia-Fairbank': (0.0, 0), 'Bayview Village': (0.0, 0), 'Kennedy Park': (0.0, 0), 'Long Branch': (0.0, 0), 'Wexford/Maryvale': (0.0, 0), 'Old East York': (0.0, 0), 'Guildwood': (0.0, 0), 'Mount Olive-Silverstone-Jamestown': (0.0, 0), 'Casa Loma': (0.0, 0), 'Cliffcrest': (0.0, 0), 'Markland Wood': (0.0, 0), 'Niagara': (0.0, 0), 'Danforth': (0.0, 0), 'Woodbine Corridor': (0.0, 0), 'Yonge-St.Clair': (0.0, 0), 'South Riverdale': (0.0, 0), 'Church-Yonge Corridor': (0.0, 0), 'Maple Leaf': (0.0, 0), 'North Riverdale': (0.0, 0), 'Willowdale West': (0.0, 0), 'Bridle Path-Sunnybrook-York Mills': (0.0, 0), 'Etobicoke West Mall': (0.0, 0), 'Junction Area': (0.0, 0), 'Wychwood': (0.0, 0), 'Newtonbrook East': (0.0, 0), 'Thorncliffe Park': (0.0, 0), 'Mount Pleasant West': (0.0, 0), 'Birchcliffe-Cliffside': (0.0, 0), 'Runnymede-Bloor West Village': (0.0, 0), 'Morningside': (0.0, 0), 'Rockcliffe-Smythe': (0.0, 0), 'Cabbagetown-South St.James Town': (0.0, 0), 'Humber Heights-Westmount': (0.0, 0), 'Elms-Old Rexdale': (0.0, 0), 'Agincourt South-Malvern West': (0.0, 0), 'Willowridge-Martingrove-Richview': (0.0, 0), 'High Park North': (0.0, 0), 'South Parkdale': (0.0, 0), 'Forest Hill South': (0.0, 0), 'Victoria Village': (0.0, 0), 'Forest Hill North': (0.0, 0), 'Weston-Pellam Park': (0.0, 0), 'Rosedale-Moore Park': (0.0, 0), 'Oakwood Village': (0.0, 0), 'Agincourt North': (0.0, 0), 'Annex': (0.0, 0), 'Kingsview Village-The Westway': (0.0, 0), 'Islington-City Centre West': (0.0, 0), 'Glenfield-Jane Heights': (0.0, 0), 'Trinity-Bellwoods': (0.0, 0), 'Kensington-Chinatown': (0.0, 0), 'Waterfront Communities-The Island': (0.0, 0), 'Leaside-Bennington': (0.0, 0), 'Bathurst Manor': (0.0, 0), 'Milliken': (0.0, 0), 'West Humber-Clairville': (0.0, 0), 'Lambton Baby Point': (0.0, 0), 'Humewood-Cedarvale': (0.0, 0), 'Steeles': (0.0, 0), 'Bedford Park-Nortown': (0.0, 0), 'Oakridge': (0.0, 0), 'Lawrence Park South': (0.0, 0), 'Blake-Jones': (0.0, 0), 'Danforth East York': (0.0, 0), 'Lawrence Park North': (0.0, 0), 'Rouge': (0.0, 0), 'Thistletown-Beaumond Heights': (0.0, 0), 'Kingsway South': (0.0, 0), 'Newtonbrook West': (0.0, 0), 'Taylor-Massey': (0.0, 0), 'Keelesdale-Eglinton West': (0.0, 0), 'Clairlea-Birchmount': (0.0, 0), 'Playter Estates-Danforth': (0.0, 0), 'Don Valley Village': (0.0, 0), 'Centennial Scarborough': (0.0, 0), 'Broadview North': (0.0, 0), 'Yorkdale-Glen Park': (0.0, 0), 'Malvern': (0.0, 0), 'Banbury-Don Mills': (0.0, 0), 'Moss Park': (0.0, 0), 'Bendale': (0.0, 0), 'Mimico (includes Humber Bay Shores)': (0.0, 0), 'Dorset Park': (0.0, 0), 'Humbermede': (0.0, 0), 'Highland Creek': (0.0, 0), 'York University Heights': (0.0, 0), 'St.Andrew-Windfields': (0.0, 0), 'Scarborough Village': (0.0, 0), 'Flemingdon Park': (0.0, 0), 'Woburn': (0.0, 0), "Tam O'Shanter-Sullivan": (0.0, 0), 'Eringate-Centennial-West Deane': (0.0, 0), 'Humber Summit': (0.0, 0), 'Ionview': (0.0, 0), 'Dovercourt-Wallace Emerson-Junction': (0.0, 0), 'Princess-Rosethorn': (0.0, 0), 'Downsview-Roding-CFB': (0.0, 0), 'Black Creek': (0.0, 0), 'Mount Dennis': (0.0, 0), 'West Hill': (0.0, 0), 'Weston': (0.0, 0), 'Englemount-Lawrence': (0.0, 0), 'Dufferin Grove': (0.0, 0), 'Alderwood': (0.0, 0), "O'Connor-Parkview": (0.0, 0), 'Brookhaven-Amesbury': (0.0, 0), 'Little Portugal': (0.0, 0), 'Clanton Park': (0.0, 0), 'Roncesvalles': (0.0, 0), 'The Beaches': (0.0, 0), 'Yonge-Eglinton': (0.0, 0), 'Pleasant View': (0.0, 0), 'Corso Italia-Davenport': (0.0, 0), 'Briar Hill-Belgravia': (0.0, 0), 'Willowdale East': (0.0, 0), 'Pelmo Park-Humberlea': (0.0, 0), 'Bay Street Corridor': (0.0, 0), 'Greenwood-Coxwell': (0.0, 0), 'East End-Danforth': (0.0, 0), 'Edenbridge-Humber Valley': (0.0, 0), 'Bayview Woods-Steeles': (0.0, 0), 'Hillcrest Village': (0.0, 0), "L'Amoreaux": (0.0, 0), 'Parkwoods-Donalda': (0.0, 0), 'University': (0.0, 0), 'High Park-Swansea': (0.0, 0), 'Mount Pleasant East': (0.0, 0), 'Rexdale-Kipling': (0.0, 0), 'North St.James Town': (0.0, 0)}

In [147]:
reviews = pd.read_csv('data')
reviews


Out[147]:
listing_id id date reviewer_id reviewer_name comments
0 18357015 155722941 2017-05-28 25772441 Michael Justin was very accommodating. He showed me hi...
1 18357015 156709127 2017-05-31 4664248 Patrick Justin was a great host, communicated quickly ...
2 81721 232477 2011-04-19 364439 Samiha My stay at Warren's loft was amazing, great op...
3 81721 299190 2011-06-06 294085 Barry The host canceled my reservation 18 days befor...
4 81721 329418 2011-06-22 90153 Rick The host canceled my reservation 37 days befor...
5 81721 1392907 2012-06-01 1871979 Mike I enjoyed this loft very much. The size is per...
6 81721 2549626 2012-10-08 2117259 Pooja I had a fantastic stay at Warren's place. The ...
7 81721 2619235 2012-10-15 3662710 Jared Warren's loft is excellent! He was very accomm...
8 81721 2970869 2012-11-26 4050088 Victoria Sleekly industrial, ultra cool, very comfortab...
9 81721 3347719 2013-01-14 3296164 Jade & Jamie Everything was great; apartment, check in, cle...
10 81721 3437854 2013-01-29 653551 Nima & Tiffany Very happy to have stayed at Living in Art Sul...
11 81721 3662241 2013-03-01 3802856 Évelyne I had a really nice stay at the loft. Even if ...
12 81721 3709963 2013-03-06 4369011 Thibault The loft was really trendy and smart. The lof...
13 81721 3906235 2013-03-26 929532 Michelle Paradise in Queen West! The loft was gorgeous,...
14 81721 4648897 2013-05-18 5565959 Vlad Notre séjour fut une réussite en grande partie...
15 81721 5106742 2013-06-12 45356 James Lovely stay at Warren's Living In Art Loft in ...
16 81721 5385118 2013-06-27 626563 Greg The apartment was great -- clean, quiet, comfo...
17 81721 6327058 2013-08-08 7351105 Jenn We really enjoyed our stay here! Our host was ...
18 81721 9736889 2014-01-07 9551714 Michelle The location was very good, walking distance ...
19 81721 16231607 2014-07-23 17575640 Christa Warren was really great at responding back to ...
20 81721 18988989 2014-09-04 6546019 Juan Sebastian Nice place to see the city from an other persp...
21 81721 19475123 2014-09-13 8886231 Karen I had the pleasure of staying at Warrens Apart...
22 81721 20385942 2014-09-28 15917698 Joel (Josh) I enjoyed my 8 nights in Warren's lovely artis...
23 81721 23960093 2014-12-15 22539851 Noelle This was a wonderful location and Warren was t...
24 81721 25330936 2015-01-12 9521373 Tom They were great hosts, easy to communicate wit...
25 81721 34781169 2015-06-12 16374272 Gameloft We book this appartment for one of our employe...
26 81721 41134761 2015-08-04 38375392 Lea Warrens loft was beautiful. Much like the pic...
27 81721 59407258 2016-01-10 39194396 Naomi I have been stay at Warren's loft for two week...
28 81721 70120718 2016-04-16 49874528 Ritu Warren was a great host. He was there when I ...
29 81721 73284117 2016-05-08 68963573 Anita The apartment was very spacious and welcoming....
... ... ... ... ... ... ...
203857 5050211 123725690 2016-12-30 106864567 Shivani Tom was very cooperative and helpful ,he also ...
203858 5050211 124745931 2017-01-02 97318812 Haoyang good host,very friendly
203859 5050211 125961381 2017-01-08 17425000 Jeremiah Nice place only didn't realize I would be shar...
203860 5050211 127043000 2017-01-15 46360435 Simon Tom's place is unique, he has many different a...
203861 5050211 128066966 2017-01-22 82915071 Alex Great place! Clean and cozy. \nTom was real...
203862 5050211 130107011 2017-02-04 103551985 Janelle Amazing apartment and great host !
203863 5050211 130342429 2017-02-05 61435842 Catherine Tom's place is very clean and well decorated. ...
203864 5050211 130942394 2017-02-09 106755317 Jasjot
203865 5050211 131554120 2017-02-12 91909708 Sandor Very clean and comfortable, Tom is a great host !
203866 5050211 132890524 2017-02-19 112335838 Shane Tom was an excellent host! He responded quickl...
203867 5050211 133090491 2017-02-20 113599258 Adrian \n
203868 5050211 133308419 2017-02-21 98849004 Reza Tom was a great host, and very responsive to a...
203869 5050211 134256379 2017-02-26 70493558 Lucy The apartment was very clean and Tom was very ...
203870 5050211 135001006 2017-03-02 55457604 Jani Really nice and clean apt. \nCommunication wit...
203871 5050211 135825075 2017-03-06 92323664 Alison Tom was a fantastic and went above and beyond ...
203872 5050211 136560367 2017-03-11 119211524 Yao It was very clean and nice place to stay at.
203873 5050211 139084617 2017-03-23 34523436 Ezzedin Quiet clean place in the heart of downtown
203874 5050211 140062912 2017-03-27 19260343 Ryan Host went above and beyond, even helped do my ...
203875 5050211 142278944 2017-04-07 40524247 Bob a gem in the city! I would highly recommend th...
203876 5050211 143575605 2017-04-12 113262139 Ushna Tom was a great host! His place was super clea...
203877 5050211 143862386 2017-04-13 30421457 James Great host and super spot to stay while you ar...
203878 5050211 146715387 2017-04-23 36615956 Kathy Tom is a welcoming and experienced host (he’s ...
203879 5050211 147415225 2017-04-26 42590078 Alex Tom is an amazing host! So kind and his place ...
203880 5050211 149318596 2017-05-03 35739759 Jillian Tom was super chill and helpful. Place is supe...
203881 5050211 149495420 2017-05-04 64325872 Naleesha Not much access to main area
203882 5050211 149865735 2017-05-06 107226734 Sohyun 위치는 다운타운과 가까워서 나름괜찮다. 밤늦으면 걸어가기는 좀 무서울수도있다. 너무...
203883 5050211 151038475 2017-05-10 32638903 Shaun Tom's apartment was extremely nice, modern and...
203884 5050211 151402429 2017-05-12 46324291 Inano Stay was short and sweet. Room and location as...
203885 5050211 155710701 2017-05-28 73854621 Tierney Beautifully decorated and tidy apartment and f...
203886 5050211 156908689 2017-06-01 100700043 Jeffery Tom was an absolute great host everything was ...

203887 rows × 6 columns


In [148]:
for i in reviews.values:
    blob = TextBlob(str(i[5]))
    n =  listings[listings.id == i[0]].neighbourhood.values[0]
    p = blob.sentiment.polarity
    l[n] = (l[n][0] + p, l[n][1] + 1)

print(l)


---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-148-eeb04987c10e> in <module>()
      2     blob = TextBlob(str(i[5]))
      3     n =  listings[listings.id == i[0]].neighbourhood.values[0]
----> 4     p = blob.sentiment.polarity
      5     l[n] = (l[n][0] + p, l[n][1] + 1)
      6 

/usr/lib/python3.5/site-packages/textblob/decorators.py in __get__(self, obj, cls)
     22         if obj is None:
     23             return self
---> 24         value = obj.__dict__[self.func.__name__] = self.func(obj)
     25         return value
     26 

/usr/lib/python3.5/site-packages/textblob/blob.py in sentiment(self)
    421         :rtype: namedtuple of the form ``Sentiment(polarity, subjectivity)``
    422         """
--> 423         return self.analyzer.analyze(self.raw)
    424 
    425     @cached_property

/usr/lib/python3.5/site-packages/textblob/en/sentiments.py in analyze(self, text)
     30         ``Sentiment(polarity, subjectivity)``.
     31         """
---> 32         return self.RETURN_TYPE(*pattern_sentiment(text))
     33 
     34 

/usr/lib/python3.5/site-packages/textblob/_text.py in __call__(self, s, negation, **kwargs)
    821         # Sentiment("a horrible movie") => (-0.6, 1.0)
    822         elif isinstance(s, basestring):
--> 823             a = self.assessments(((w.lower(), None) for w in " ".join(self.tokenizer(s)).split()), negation)
    824         # A pattern.en.Text.
    825         elif hasattr(s, "sentences"):

/usr/lib/python3.5/site-packages/textblob/_text.py in find_tokens(self, string, **kwargs)
   1175               abbreviations = kwargs.get("abbreviations", ABBREVIATIONS),
   1176                     replace = kwargs.get(      "replace", replacements),
-> 1177                   linebreak = r"\n{2,}")
   1178 
   1179     def find_tags(self, tokens, **kwargs):

/usr/lib/python3.5/site-packages/textblob/_text.py in find_tokens(string, punctuation, abbreviations, replace, linebreak)
    298                     if t in abbreviations or \
    299                       RE_ABBR1.match(t) is not None or \
--> 300                       RE_ABBR2.match(t) is not None or \
    301                       RE_ABBR3.match(t) is not None:
    302                         break

KeyboardInterrupt: 

In [149]:
for i in l:
    v = l[i][0]/(l[i][1]+0.0001)
    l[i] = v

In [154]:
res = pd.DataFrame(list(l.items()),columns=['neighborhood', 'reviews'], )
res.reset_index()
min_ = res.reviews.min()
max_ = res.reviews.max()

res.reviews = res.reviews.apply(lambda x: ((x-min_)/(max_ - min_)))

In [159]:
res.to_csv("ratings.csv")

In [169]:
import json
demo = {
    'result': res.to_dict(orient='record')
}


with open('ratings.json', 'w') as outfile:
    json.dump(demo, outfile)

In [33]:
import os,json
with open(os.path.join('ratings.json')) as f:
    ratings = f.read()
with open(os.path.join('assaults.json')) as f:
    assaults = f.read()
with open(os.path.join('pricy.json')) as f:
    pricy = f.read()

In [34]:
ratings = json.loads(ratings)
assaults = json.loads(assaults)

In [43]:
n1 = set()
for i in ratings["result"]:
    n1.add(i['neighborhood'])
    
print(len(n1))

n2 = set()
for i in assaults["result"]:
    n2.add(i['neighborhood'])
    
print(len(n2))

inter = n2.intersection(n1)

print(len(inter))

"Palmerston-Little Italy" in inter


139
140
130
Out[43]:
True

In [44]:
2**2


Out[44]:
4