<jupyter_start><jupyter_text>====================================================== MA477 - Theory and Applications of Data Science   Homework 2: Pandas   Dr. <NAME>  United States Military Academy, West Point, AY20-2=======================================================  Cadet Name: <NAME>Date: 27 January 2020  X MY DOCUMENTATION IDENTIFIES ALL SOURCES USED AND ASSISTANCE RECEIVED IN THIS ASSIGNMENT$\dots \dots$  I DID NOT USE ANY SOURCES OR ASSISTANCE REQUIRING DOCUMENATION IN COMPLETING THIS ASSIGNMENT Signature/Initials:JHL  Complete the following tasks:  Import Pandas and Numpy<jupyter_code>#Enter your code here
import pandas as pd
import numpy as np<jupyter_output><empty_output><jupyter_text>Read-in the file named Airbnb_Dataset and assign it to a variable names abnb(Make sure that the file is in the same folder as your Homework2 JupyterNotebook)<jupyter_code>abnb=pd.read_excel('Airbnb_Dataset.xlsx')<jupyter_output><empty_output><jupyter_text>Show the head of the dataframe<jupyter_code>#Your code goes here
abnb.head()<jupyter_output><empty_output><jupyter_text>Find how many different neighborhoods are there in Manhattan and list all of them?<jupyter_code>#Answer for number of different neighborhoods in Manhattan
abnb[abnb['neighbourhood_group']=='Manhattan']['neighbourhood'].nunique()
#Your answer for the list of all different neighborhoods in Manhattan
abnb[abnb['neighbourhood_group']=='Manhattan']['neighbourhood'].unique()<jupyter_output><empty_output><jupyter_text>How many different shared rooms are listed?<jupyter_code>#Your answer
abnb[abnb['room_type'] == 'Shared room']['id'].nunique()<jupyter_output><empty_output><jupyter_text>Find all the listings of room type  Shared rooms in  Manhattan with a price range of  \$60$-$\$75 and that have received over 100 reviews<jupyter_code>#Enter your answer here
abnb[(abnb['room_type'] == 'Shared room') & (abnb['neighbourhood_group'] == 'Manhattan') &  
     (abnb['price'] >= 60) &  (abnb['price'] <= 75) &  (abnb['number_of_reviews'] > 100) ]<jupyter_output><empty_output><jupyter_text>Find the minimum, maximum, and average values for both price and  number of reviews for the listings in each of the different neighbourhoods of Manhattan<jupyter_code>#Your answer
abnb[abnb['neighbourhood_group']=='Manhattan'].groupby(by='neighbourhood').agg({'price':[np.min,np.mean,np.max],
                                                                                'number_of_reviews':[np.min,np.mean,np.max]})<jupyter_output><empty_output><jupyter_text>Challenging!!!Find all the listings that have any version (upper case, lower case, mix etc.) of the following two phrases  Females Only and  Comfy Couch in the name column of the  abnb dataframe. Display only the id, name, host_name, price, and  neighbourhood_group<jupyter_code>#Don't change this
pd.set_option('display.max_colwidth', -1)
#Your answer goes here
abnb[(abnb['name'].str.contains("Females Only",case = False)) | (abnb['name'].str.contains("Comfy Couch",case = False))][['id','name','host_name','price','neighbourhood_group']]<jupyter_output><empty_output><jupyter_text>Work Cited<jupyter_code>#https://stackoverflow.com/questions/30944577/check-if-string-is-in-a-pandas-dataframe
#https://stackoverflow.com/questions/32616261/filtering-pandas-dataframe-rows-by-contains-str<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1423455684870188, 'fraction_numerical': 0.01342882721575649, 'mean_word_length': 6.4323725055432375, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 41, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '638283', 'license': 'MIT', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1044, 'n_words': 272, 'path': 'MA477 - Theory and Applications of Data Science/Homework/Student Solutions/Homework 2/Lee_John_MA477_Homework2.ipynb', 'repo_name': 'jkstarling/MA477-copy', 'size': '3359'}