<jupyter_start><jupyter_text>AttendancePlease mark your attendance [here](https://forms.office.com/Pages/ResponsePage.aspx?id=MH_ksn3NTkql2rGM8aQVG-ma-csIdQlCgCfjKacBoUlUQTY5VllKWUcwSE5KS0E5RzlBTVdZTVZYVC4u).  01 - Estimating metricsOften, the data we are provided does not (yet) contain the metrics we need. In these first exercises, we are going to load in some data (similar to the data we used before) and estimate some useful metrics.  Loading and understanding dataLet's import `pandas`, load in our dataset, and `print` the columns in the dataset.(Note: the dataset is named `wk3_listings_sample.csv` becuase it is slightly different from before)<jupyter_code>import pandas as pd
df_listings = pd.read_csv('../data/wk3_listings_sample.csv')
print(df_listings.columns)<jupyter_output><empty_output><jupyter_text>As you can see, there are lots of columns in this dataset. If you would like to understand the columns better, then you can look at the [data dictionary](https://docs.google.com/spreadsheets/d/1iWCNJcSutYqpULSQHlNyGInUvHg2BoUGoNRIGa6Szc4/editgid=982310896) of the dataset.  Exercise-01: Understanding columns**Questions** What do the values in the `minimum_maximum_nights` column represent?  Price per personYou are asked to estimate the "price per person" for each listing in the dataset. To do this, you first need to format the `price` column to contain  values you can perform calculations on (like we did last week). Let's do this below. Create a `price_$` column with the price of the listing in \$'s in `float` format, and show the `head` of the `price` and `price_$` columns to check it worked OK.<jupyter_code># (SOLUTION)
def format_price(price):
    return(float(price.replace('$','').replace(',','')))

df_listings['price_$'] = df_listings['price'].apply(format_price)
df_listings[['price','price_$']].head()<jupyter_output><empty_output><jupyter_text>Exercise-02: Estimate price-per-personWith the price values in a `float` format, we can use the `/` (division) operator to divide the values in the `price_$` column by the values in the `accommodates` column, and create a new column named `price_$/person`. Run the code shown below to do this and show the `head` of the relevant columns to check it's working OK.<jupyter_code>df_listings['price_$/person'] = df_listings['price_$'] / df_listings['accommodates']
df_listings[['price_$','accommodates','price_$/person']].head()<jupyter_output><empty_output><jupyter_text>We can also sort the rows of `df_listings` by the values in column `price_$/person` to identify which listing has the highest `price_$/person` of all the listings in the dataset. Run the code below to show the neighbourhood of the listing with the highest `price_$/person` in the dataset.<jupyter_code>df_listings.sort_values(by='price_$/person', ascending=False).head(1)['neighbourhood_cleansed']<jupyter_output><empty_output><jupyter_text>**Question:** What neighbourhood is it in? Look again in the [data dictionary](https://docs.google.com/spreadsheets/d/1iWCNJcSutYqpULSQHlNyGInUvHg2BoUGoNRIGa6Szc4/editgid=982310896) to understand what values in the `accommodates` column represent. **Question:** Do you think using `accomodates` is a good way to estimate the price per person for each listing? If not, why not?**Question:** Why might someone want to estimate the price per person for each listing?  Forecasting incomeYou are asked to forecast how much money (in \$'s) each listing is likely to receive over the next 30 days. To do this, you decide to use the `availability_30` column to calculate how many nights of the next available 30 nights are booked and then multiple this number by the `price_$` using the `*` (multiplication) operator.  Exercise-03: Forecast 30-day incomeComplete the code below to estimate the income for each listing over the next 30 days. Look at Exercise-02, to start.<jupyter_code>df_listings['estimated_income_30'] = # (SOLUTION)
df_listings[['price_$','availability_30', 'estimated_income_30']].head()<jupyter_output><empty_output><jupyter_text>In the code block below, sort the values of `df_listings` by the values in `esimated_income_30` to identify the listing with highest forecasted income for the next 30 days.<jupyter_code># (SOLUTION)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09502580947911779, 'fraction_numerical': 0.015720319099014547, 'mean_word_length': 6.324742268041237, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '477784', 'license': 'MIT', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1302, 'n_words': 481, 'path': 'exercises/01 - Calculating metrics.ipynb', 'repo_name': 'data-analytics-in-business/week-03', 'size': '4262'}